Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error message for casting pointer difference is confusing #2239

@orangebowlerhat

Description

@orangebowlerhat

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions