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

Signedness Checker emits false positive error with casted unsigned right shift expression #3667

Closed
DmitriyShepelev opened this issue Sep 17, 2020 · 0 comments · Fixed by #3683

Comments

@DmitriyShepelev
Copy link
Contributor

DmitriyShepelev commented Sep 17, 2020

The Signedness Checker emits a false positive error when the left operand of a casted (without an explicit signedness annotation) unsigned right shift expression is either a method parameter or field:

import org.checkerframework.checker.signedness.qual.Unsigned;
import org.checkerframework.checker.signedness.qual.Signed;

public class UnsignedRightShiftTestShort {
    void unsignedRightShiftWithParameter(int length) {
        byte b1 = (byte) (length >>> 24);
        byte b2 = (@Unsigned byte) (length >>> 24);
        byte b3 = (@Signed byte) (length >>> 24);
    }
}

Command: javacheck -version -verbose -AprintAllQualifiers -processor SignednessChecker UnsignedRightShiftTestShort.java

Output:
UnsignedRightShiftTestShortOutput.txt

javacheck alias:
alias javacheck='$CHECKERFRAMEWORK/checker/bin/javac'

In particular, the line byte b1 = (byte) (length >>> 24); emits the false positive error. This line should be legal, according to section 18.2.2 Permitted Shifts in the user manual.

DmitriyShepelev added a commit to DmitriyShepelev/checker-framework that referenced this issue Sep 18, 2020
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.

1 participant