Error message for casting pointer difference is confusing
Given code like this
char* a = 0x20; // not a sensible value, just for example purposes
char* b = 0x25;
uint diff = b - a;
Produces the error message
Error: 'isz' (long) cannot implicitly be converted to 'uint', but you may use a cast.
This message is confusing. It's unclear what to solve given that the error mentions 'isz' but nothing in the error line is a size value. A message more like the following might explain the problem better.
The difference of two pointers cannot be implicitly converted to 'uint', but you may use a cast
This should be fixed now.
Is this working?
On both v0.7.2 and v0.7.3 I get an error about the char* a = 0x20; part.
- On
0.7.2the error is
Error: Implicitly casting 'char' to 'char*' is not permitted, but you may do an explicit cast...
- On
0.7.3the error is
Error: Implicitly casting 'uint' to 'char*' is not permitted...
That changed too apparently, but ok.
When I add the casts for those and look at the errors for uint diff = b - a;, then
- On
0.7.2:
Error: 'isz' (long) cannot implicitly be converted to 'uint', but you may use a cast.
- On
0.7.3:
Error: A pointer diff has the type 'isz' (long) which cannot implicitly be converted to 'uint'. You can use an explicit cast if you know the conversion is safe.
That looks correct. I'll close it. Thank you for checking @BWindey