diff --git a/regression/goto-instrument/show-escape-analysis1/main.c b/regression/goto-instrument/show-escape-analysis1/main.c new file mode 100644 index 00000000000..49ae788433c --- /dev/null +++ b/regression/goto-instrument/show-escape-analysis1/main.c @@ -0,0 +1,13 @@ +#include + +void foo() +{ + int *leaked1=malloc(sizeof(int)); + int *leaked2=malloc(sizeof(int)); +} + +int main() +{ + foo(); + return 0; +} diff --git a/regression/goto-instrument/show-escape-analysis1/test.desc b/regression/goto-instrument/show-escape-analysis1/test.desc new file mode 100644 index 00000000000..60bbfcb71db --- /dev/null +++ b/regression/goto-instrument/show-escape-analysis1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-escape-analysis +^EXIT=0$ +^SIGNAL=0$ +^Aliases:.*(malloc.*leaked|leaked.*malloc) +-- +^Aliases:.*(leaked1.*leaked2|leaked1.*leaked2) +^warning: ignoring +-- +leaked1 and leaked2 cannot alias diff --git a/src/analyses/escape_analysis.cpp b/src/analyses/escape_analysis.cpp index 5b4585d421b..90fc7f5f87c 100644 --- a/src/analyses/escape_analysis.cpp +++ b/src/analyses/escape_analysis.cpp @@ -305,16 +305,8 @@ bool escape_domaint::merge( locationt from, locationt to) { - if(b.has_values.is_false()) - return false; // no change - - if(has_values.is_false()) - { - *this=b; - return true; // change - } - - bool changed=false; + bool changed=has_values.is_false(); + has_values=tvt::unknown(); for(const auto &cleanup : b.cleanup_map) { diff --git a/src/util/union_find.h b/src/util/union_find.h index f871ad669c7..faf472d341f 100644 --- a/src/util/union_find.h +++ b/src/util/union_find.h @@ -169,7 +169,7 @@ class union_find final bool same_set(const T &a, const T &b) const { const optionalt na = numbers.get_number(a); - const optionalt nb = numbers.get_number(a); + const optionalt nb = numbers.get_number(b); if(na && nb) return uuf.same_set(*na, *nb);