Skip to content

Commit 74406a0

Browse files
committed
goto_rw: left shift may be larger than object size
While such an expression might have undefined behaviour in some source languages, goto_rw should not assert that a goto program does not contain such an expression.
1 parent 7127c4d commit 74406a0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CORE
2+
leftshift_overflow.c
3+
--signed-overflow-check --c99 --full-slice
4+
^EXIT=10$
5+
^SIGNAL=0$
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
13+
^VERIFICATION FAILED$
14+
--
15+
^warning: ignoring
16+
^\[.*\] line 14 arithmetic overflow on signed shl in .*: .*
17+
^\[.*\] line 23 arithmetic overflow on signed shl in .*: .*

src/analyses/goto_rw.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,8 @@ void rw_range_sett::get_objects_shift(
212212
if(sh_range_start>=0 && sh_range_start<src_size)
213213
get_objects_rec(mode, shift.op(), sh_range_start, sh_size);
214214
}
215-
else
215+
if(src_size - dist_r >= 0)
216216
{
217-
assert(src_size-dist_r>=0);
218217
range_spect sh_size=std::min(size, src_size-dist_r);
219218

220219
get_objects_rec(mode, shift.op(), range_start, sh_size);

0 commit comments

Comments
 (0)