File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
regression/cbmc/Overflow_Leftshift1 Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11int main ()
22{
33 unsigned char x ;
4+
5+ // signed, owing to promotion, and may overflow
46 unsigned r = x << ((sizeof (unsigned )-1 )* 8 );
7+
8+ // signed, owing to promotion, and cannot overflow
59 r = x << ((sizeof (unsigned )-1 )* 8 - 1 );
10+
11+ // unsigned
612 r = (unsigned )x << ((sizeof (unsigned )-1 )* 8 );
713
8- int s = -1 << ((sizeof (int )-1 )* 8 );
9- s = -256 << ((sizeof (int )-1 )* 8 );
14+ // negative value or zero, not an overflow
15+ int s = - x << ((sizeof (int ) - 1 ) * 8 );
16+
17+ // overflow
18+ s = 1 << x ;
19+
1020 return 0 ;
1121}
Original file line number Diff line number Diff line change 33--signed-overflow-check
44^EXIT=10$
55^SIGNAL=0$
6- ^\[.*\] .* arithmetic overflow on signed shl in .*: FAILURE$
7- ^\*\* 2 of 4 failed
6+ ^\[.*\] line 6 arithmetic overflow on signed shl in .*: FAILURE$
7+ ^\[.*\] line 9 arithmetic overflow on signed shl in .*: SUCCESS$
8+ ^\[.*\] line 15 arithmetic overflow on signed shl in .*: SUCCESS$
9+ ^\[.*\] line 18 arithmetic overflow on signed shl in .*: FAILURE$
10+ ^\*\* 2 of 5 failed
811^VERIFICATION FAILED$
912--
1013^warning: ignoring
14+ ^\[.*\] line 12 arithmetic overflow on signed shl in .*: .*
15+ ^\[.*\] line 21 arithmetic overflow on signed shl in .*: .*
You can’t perform that action at this time.
0 commit comments