Skip to content

Commit 41bafc0

Browse files
Merge pull request #1375 from pkesseli/bugfix/uncaught-exceptions-invariant
Account for replaced functions in exceptions_map
2 parents 2816b80 + 0496142 commit 41bafc0

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int main(void)
2+
{
3+
int x;
4+
__CPROVER_assume(x < 10);
5+
__CPROVER_assert(x != 0, "");
6+
return 0;
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
VERIFICATION FAILED
7+
--
8+
^warning: ignoring
9+
--
10+
When compiling CBMC with -DDEBUG uncaught exception analysis prints an
11+
exceptions map per function. This test ensures that meta-functions which are
12+
replaced by explicit GOTO instructions (e.g. __CPROVER_assert, __CPROVER_assume)
13+
and thus do not occur as explicit function calls in the final GOTO program are
14+
handled correctly.

src/analyses/uncaught_exceptions_analysis.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ void uncaught_exceptions_analysist::output(
193193
{
194194
const auto fn=it->first;
195195
const exceptions_mapt::const_iterator found=exceptions_map.find(fn);
196-
INVARIANT(
197-
found!=exceptions_map.end(),
198-
"each function expected to be recorded in `exceptions_map`");
196+
// Functions like __CPROVER_assert and __CPROVER_assume are replaced by
197+
// explicit GOTO instructions and will not show up in exceptions_map.
198+
if(found==exceptions_map.end())
199+
continue;
200+
199201
const auto &fs=found->second;
200202
if(!fs.empty())
201203
{

0 commit comments

Comments
 (0)