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

False positive when comparing two char with the Signedness checker #5166

Closed
txiang61 opened this issue Jun 17, 2022 · 2 comments · Fixed by #5167
Closed

False positive when comparing two char with the Signedness checker #5166

txiang61 opened this issue Jun 17, 2022 · 2 comments · Fixed by #5167

Comments

@txiang61
Copy link
Contributor

Signedness checker complains about comparison between two char.

private static boolean isWhitespace(char c) {
    return c <= '\u0020';
}

Gives the following error:

error: [comparison.unsignedlhs] comparison has an unsigned LHS
    return c <= '\u0020';
           ^

From JLS https://docs.oracle.com/javase/specs/jls/se9/html/jls-5.html#jls-5.1.2

A widening conversion of a char to an integral type T zero-extends the representation of the char value to fill the wider format.

Comparison between two char should be safe.

mernst added a commit to mernst/checker-framework that referenced this issue Jun 17, 2022
@mernst mernst linked a pull request Jun 18, 2022 that will close this issue
mernst added a commit that referenced this issue Jun 18, 2022
@mernst
Copy link
Member

mernst commented Jun 18, 2022

I agree that the code you gave should pass type-checking. It seems to do so; see pull request #5167.

What version of the Checker Framework are you using?

@txiang61
Copy link
Contributor Author

Thanks good to know it's already fixed. I'm on a very old version. Will update.

wmdietl pushed a commit to eisop/checker-framework that referenced this issue Jul 13, 2022
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 a pull request may close this issue.

2 participants