Skip to content

Less Than Checker: a floating-point comparison does not imply an integral bound - #8716

Merged
mernst merged 2 commits into
typetools:masterfrom
mernst:index-floating-point-integral-bound
Nov 30, 2026
Merged

mernst merged 2 commits into
typetools:masterfrom
mernst:index-floating-point-integral-bound

Conversation

@mernst

@mernst mernst commented Nov 29, 2026

Copy link
Copy Markdown
Member

Land before #8459.

A comparison of an integral value with a floating-point value converts the integral value to the floating-point type, which might round it. Therefore, such a comparison does not imply an integral bound. If the float f is 16777216.0f and the int i is 16777217, then f >= i is true, because i rounds to 16777216.0f, but i < f + 1 is false. In the then branch of f >= i, the Less Than Checker refined i to @LessThan("f + 1").

Now the Less Than Checker does not refine either operand of a floating-point comparison. It uses IndexAbstractTransfer.isFloatingPointComparison (from #8636), which is now protected and takes the two operands.

Tests: checker/tests/index/LessThanFloatComparison.java.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4cce248 and d0fcfb8.

Files selected for processing: 3

  • checker/src/main/java/org/checkerframework/checker/index/IndexAbstractTransfer.java
  • checker/src/main/java/org/checkerframework/checker/index/inequality/LessThanTransfer.java
  • checker/tests/index/LessThanFloatComparison.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mernst mernst self-assigned this Nov 29, 2026
@mernst
mernst merged commit 1ba6837 into typetools:master Nov 30, 2026
29 checks passed
@mernst
mernst deleted the index-floating-point-integral-bound branch November 30, 2026 06:12
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

Successfully merging this pull request may close these issues.

1 participant