diff --git a/regression/goto-analyzer/dependence-graph14/main.c b/regression/goto-analyzer/dependence-graph14/main.c new file mode 100644 index 00000000000..82d0a3aea19 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph14/main.c @@ -0,0 +1,8 @@ +int main() +{ + int a[10]; + a[2] = 2; + a[1] = 1; + int out = a[2]; + return out; +} diff --git a/regression/goto-analyzer/dependence-graph14/test.desc b/regression/goto-analyzer/dependence-graph14/test.desc new file mode 100644 index 00000000000..bab0c027748 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph14/test.desc @@ -0,0 +1,26 @@ +CORE +main.c +--dependence-graph --show +activate-multi-line-match +^EXIT=0$ +^SIGNAL=0$ +\/\/ ([0-9]+).*\n.*a\[\(signed long( long)? int\)2\] = 2;(.*\n)*Data dependencies: (\1)\n(.*\n){2,3}.*out = * +-- +\/\/ ([0-9]+).*\n.*a\[\(signed long( long)? int\)1\] = 1;(.*\n)*Data dependencies: (\1)\n(.*\n){2,3}.*out = * +^warning: ignoring +-- + +The two regex above matches output portions like shown below (with being a +location number). The intention is to make sure the rw_set recognize the range +of the assignment to an array index correctly. + + // file main.c line 4 function main + a[(signed long int)2] = 2; + ... + +**** 4 file main.c line 6 function main +Data dependencies: + + // 4 file main.c line 6 function main + out = a[(signed long int)2]; + diff --git a/src/analyses/goto_rw.cpp b/src/analyses/goto_rw.cpp index 55236145ab8..61e7467669b 100644 --- a/src/analyses/goto_rw.cpp +++ b/src/analyses/goto_rw.cpp @@ -542,7 +542,7 @@ void rw_range_sett::get_objects_rec( { range_spect range_end=size==-1 ? -1 : range_start+size; if(size!=-1 && full_size!=-1) - range_end=std::max(range_end, full_size); + range_end=std::min(range_end, full_size); add(mode, identifier, range_start, range_end); }