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
+
1
3
int main ()
2
4
{
3
5
unsigned char x ;
@@ -23,5 +25,9 @@ int main()
23
25
// not an overflow in ANSI-C, but undefined in C99
24
26
s = 1 << (sizeof (int ) * 8 - 1 );
25
27
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
+
26
32
return 0 ;
27
33
}
Original file line number Diff line number Diff line change 3
3
--signed-overflow-check --c89
4
4
^EXIT=10$
5
5
^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
11
12
^VERIFICATION FAILED$
12
13
--
13
14
^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 3
3
--signed-overflow-check --c99
4
4
^EXIT=10$
5
5
^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
12
13
^VERIFICATION FAILED$
13
14
--
14
15
^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(
777
777
if (distance_type.id () == ID_unsignedbv)
778
778
neg_dist_shift = false_exprt ();
779
779
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
+ }
782
784
783
785
// shifting a non-zero value by more than its width is undefined;
784
786
// yet this isn't an overflow
You can’t perform that action at this time.
0 commit comments