File tree Expand file tree Collapse file tree 4 files changed +28
-18
lines changed
regression/cbmc/Overflow_Leftshift1 Expand file tree Collapse file tree 4 files changed +28
-18
lines changed Original file line number Diff line number Diff line change 1+ #include <inttypes.h>
2+
13int main ()
24{
35 unsigned char x ;
@@ -23,5 +25,9 @@ int main()
2325 // not an overflow in ANSI-C, but undefined in C99
2426 s = 1 << (sizeof (int ) * 8 - 1 );
2527
28+ // overflow in an expression where operand and distance types are different
29+ uint32_t u32 ;
30+ int64_t i64 = ((int64_t )u32 ) << 32 ;
31+
2632 return 0 ;
2733}
Original file line number Diff line number Diff line change 33--signed-overflow-check --c89
44^EXIT=10$
55^SIGNAL=0$
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
6+ ^\[.*\] line 8 arithmetic overflow on signed shl in .*: FAILURE$
7+ ^\[.*\] line 11 arithmetic overflow on signed shl in .*: SUCCESS$
8+ ^\[.*\] line 17 arithmetic overflow on signed shl in .*: SUCCESS$
9+ ^\[.*\] line 20 arithmetic overflow on signed shl in .*: FAILURE$
10+ ^\[.*\] line 30 arithmetic overflow on signed shl in .*: SUCCESS$
11+ ^\*\* 2 of 6 failed
1112^VERIFICATION FAILED$
1213--
1314^warning: ignoring
14- ^\[.*\] line 12 arithmetic overflow on signed shl in .*: .*
15- ^\[.*\] line 21 arithmetic overflow on signed shl in .*: .*
16- ^\[.*\] line 24 arithmetic overflow on signed shl in .*: .*
15+ ^\[.*\] line 14 arithmetic overflow on signed shl in .*: .*
16+ ^\[.*\] line 23 arithmetic overflow on signed shl in .*: .*
17+ ^\[.*\] line 26 arithmetic overflow on signed shl in .*: .*
Original file line number Diff line number Diff line change 33--signed-overflow-check --c99
44^EXIT=10$
55^SIGNAL=0$
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- ^\[.*\] line 24 arithmetic overflow on signed shl in .*: FAILURE$
11- ^\*\* 3 of 6 failed
6+ ^\[.*\] line 8 arithmetic overflow on signed shl in .*: FAILURE$
7+ ^\[.*\] line 11 arithmetic overflow on signed shl in .*: SUCCESS$
8+ ^\[.*\] line 17 arithmetic overflow on signed shl in .*: SUCCESS$
9+ ^\[.*\] line 20 arithmetic overflow on signed shl in .*: FAILURE$
10+ ^\[.*\] line 26 arithmetic overflow on signed shl in .*: FAILURE$
11+ ^\[.*\] line 30 arithmetic overflow on signed shl in .*: FAILURE$
12+ ^\*\* 4 of 7 failed
1213^VERIFICATION FAILED$
1314--
1415^warning: ignoring
15- ^\[.*\] line 12 arithmetic overflow on signed shl in .*: .*
16- ^\[.*\] line 21 arithmetic overflow on signed shl in .*: .*
16+ ^\[.*\] line 14 arithmetic overflow on signed shl in .*: .*
17+ ^\[.*\] line 23 arithmetic overflow on signed shl in .*: .*
Original file line number Diff line number Diff line change @@ -777,8 +777,10 @@ void goto_checkt::integer_overflow_check(
777777 if (distance_type.id () == ID_unsignedbv)
778778 neg_dist_shift = false_exprt ();
779779 else
780- neg_dist_shift =
781- binary_relation_exprt (op, ID_lt, from_integer (0 , distance_type));
780+ {
781+ neg_dist_shift = binary_relation_exprt (
782+ distance, ID_lt, from_integer (0 , distance_type));
783+ }
782784
783785 // shifting a non-zero value by more than its width is undefined;
784786 // yet this isn't an overflow
You can’t perform that action at this time.
0 commit comments