File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
regression/cbmc-incr-smt2/bitvector-bitwise-operators Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ CORE
2+ bitwise_ops.c
3+ --incremental-smt2-solver 'z3 --smt2 -in' --slice-formula
4+ \[main\.assertion\.1\] line \d+ This is going to fail for bit-opposites: FAILURE
5+ \[main\.assertion\.2\] line \d+ This is going to hold for all values != 0: SUCCESS
6+ \[main\.assertion\.3\] line \d+ This is going to fail for the same value in A and B: FAILURE
7+ \[main\.assertion\.4\] line \d+ This will fail for the the same value in A and B: FAILURE
8+ ^EXIT=10$
9+ ^SIGNAL=0$
10+ --
11+ --
Original file line number Diff line number Diff line change 1+ int main ()
2+ {
3+ int a ;
4+ int b ;
5+
6+ __CPROVER_assume (a != 0 );
7+
8+ // This is going to be failing for values of `0000` and `1111` (as an example),
9+ // as the bitwise-& of that will produce 0, failing this assertion.
10+ __CPROVER_assert (a & b , "This is going to fail for bit-opposites" );
11+ // This will always be true, because bitwise-or allows a 1 at a bit
12+ // that either A or B have set as one, and with an assumption of
13+ // a != 0, there's always going to be at least 1 bit set, allowing
14+ // the assertion below to evaluate to true.
15+ __CPROVER_assert (a | b , "This is going to hold for all values != 0" );
16+ // This will fail for the same value, as an XOR of the bits will
17+ // result in `0`, resulting in the assertion failure.
18+ __CPROVER_assert (
19+ a ^ b , "This is going to fail for the same value in A and B" );
20+ // This will fail for the exact same value of A and B, as
21+ // NOT(A) will flip all the bits, resulting in the equality
22+ // below to be false for the assertion.
23+ __CPROVER_assert (~a == b , "This will fail for the the same value in A and B" );
24+ }
You can’t perform that action at this time.
0 commit comments