A comparison operator (< > <= >=) between distinct integral types might hide a bug
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
An expression like `someInt < someLong` is at least "fishy" (no offense to our aquatic friends), because assuming that the wider type actually _needs_ to be wider (can't be safely cast down to the narrower type), then this expression will always have the same result every time it executes. This seems to have some reasonable chance of being not-what-the-user-really-intended.
Example - this loop might never terminate:
```
long limit = ...
for (int i = 0 ; i < limit ; i++) {
...
}
```
(EDIT: if either operand is a constant expression, this issue doesn't really apply in the same way; we should reason based on its actual value instead of worrying about ranges. Also, this issue doesn't apply in the same when comparing say an int to a double; I was thinking of integral types.)
Contributor guide
Assessment
This issue has not been assessed yet.