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

Non-short-circuiting operators are short-circuiting #1287

Open
superaxander opened this issue Nov 29, 2024 · 0 comments
Open

Non-short-circuiting operators are short-circuiting #1287

superaxander opened this issue Nov 29, 2024 · 0 comments
Labels
A-Bug F-Java Frontend: Java

Comments

@superaxander
Copy link
Member

In Java the following program verifies where it shouldn't:

class Test {
    int a;

    //@ context Perm(a, write);
    //@ ensures a == \old(a) + 1;
    //@ ensures !\result;
    boolean inc() {
        a += 1;
        return false;
    }

    //@ context Perm(a, write);
    //@ requires a == 0;
    void foo() {
        boolean b = inc() & inc();
        //@ assert !b;
        // Should fail because & is not short-circuiting (i.e. a should be 2
        //@ assert a == 1;
    }
}

In the Disambiguate rewrite pass bitwise operations on booleans are simply replaced with the short-circuiting operator variants. (The other front ends either don't parse the bitwise operators at all or keep them until the end crashing VerCors)

@superaxander superaxander added A-Bug F-Java Frontend: Java labels Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Bug F-Java Frontend: Java
Projects
None yet
Development

No branches or pull requests

1 participant