Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe cast warning by Less Than Checker when narrowing an index with a constant upper bound #222

Open
panacekcz opened this issue Apr 4, 2018 · 0 comments

Comments

@panacekcz
Copy link

The Less Than Checker reports an error when casting an index with a constant upper bound.

Example (from Guava):

public class LessThanCast {
 void m() {
  byte [] result = new byte[128];
  for (int i = 0; i <= 9; i++) {
   result['0' + i] = (byte) i;
  }
 }
}

Output:

/home/vlasta/workspace/CFExperiments/src/LessThanCast.java:5: warning: [cast.unsafe] "@LessThan("9 + 1") int" may not be casted to the type "@LessThan("10") byte"
   result['0' + i] = (byte) i;
                     ^
1 warning

Expected: no warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant