Skip to content

Commit 5d3ea03

Browse files
authored
Merge pull request diffblue#2693 from zhixing-xu/fix_rw_range_upper
Fixed a bug where the rw_set range not being set correctly
2 parents c6d0427 + 2b40338 commit 5d3ea03

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
int main()
2+
{
3+
int a[10];
4+
a[2] = 2;
5+
a[1] = 1;
6+
int out = a[2];
7+
return out;
8+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CORE
2+
main.c
3+
--dependence-graph --show
4+
activate-multi-line-match
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
\/\/ ([0-9]+).*\n.*a\[\(signed long( long)? int\)2\] = 2;(.*\n)*Data dependencies: (\1)\n(.*\n){2,3}.*out = *
8+
--
9+
\/\/ ([0-9]+).*\n.*a\[\(signed long( long)? int\)1\] = 1;(.*\n)*Data dependencies: (\1)\n(.*\n){2,3}.*out = *
10+
^warning: ignoring
11+
--
12+
13+
The two regex above matches output portions like shown below (with <N> being a
14+
location number). The intention is to make sure the rw_set recognize the range
15+
of the assignment to an array index correctly.
16+
17+
// <N> file main.c line 4 function main
18+
a[(signed long int)2] = 2;
19+
...
20+
21+
**** 4 file main.c line 6 function main
22+
Data dependencies: <N>
23+
24+
// 4 file main.c line 6 function main
25+
out = a[(signed long int)2];
26+

src/analyses/goto_rw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ void rw_range_sett::get_objects_rec(
542542
{
543543
range_spect range_end=size==-1 ? -1 : range_start+size;
544544
if(size!=-1 && full_size!=-1)
545-
range_end=std::max(range_end, full_size);
545+
range_end=std::min(range_end, full_size);
546546

547547
add(mode, identifier, range_start, range_end);
548548
}

0 commit comments

Comments
 (0)