Skip to content

Commit ea500da

Browse files
authored
Merge pull request #7494 from tautschnig/bugfixes/7473-recursion
Fix symex coverage reporting of recursive calls
2 parents 85b7bb9 + 1412b19 commit ea500da

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
int factorial(int n)
2+
{
3+
if(n == 0)
4+
{
5+
return 1;
6+
}
7+
return n * factorial(n - 1);
8+
}
9+
10+
int main(void)
11+
{
12+
int result = factorial(5);
13+
return 0;
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--symex-coverage-report - --unwind 1
4+
<line branch="true" condition-coverage="50% \(1/2\)" hits="2" number="3">
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
^warning: ignoring
10+
^Invariant check failed

regression/validate-trace-xml-schema/check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
# produces intermingled XML on the command line
5151
['coverage_report1', 'test.desc'],
5252
['coverage_report1', 'paths.desc'],
53+
['coverage_report2', 'test.desc'],
5354
['graphml_witness1', 'test.desc'],
5455
['switch8', 'program-only.desc'],
5556
['Failing_Assert1', 'dimacs.desc'],

src/goto-checker/symex_coverage.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,12 @@ void goto_program_coverage_recordt::compute_coverage_lines(
236236
symex_coveraget::coveraget::const_iterator c_entry = coverage.find(it);
237237
if(c_entry != coverage.end())
238238
{
239-
if(!(c_entry->second.size() == 1 || is_branch))
240-
{
241-
std::cerr << it->location_number << '\n';
242-
for(const auto &cov : c_entry->second)
243-
std::cerr << cov.second.succ->location_number << '\n';
244-
}
245-
DATA_INVARIANT(
246-
c_entry->second.size() == 1 || is_branch,
247-
"instructions other than branch instructions have exactly 1 successor");
239+
DATA_INVARIANT_WITH_DIAGNOSTICS(
240+
c_entry->second.size() == 1 || is_branch || it->is_function_call(),
241+
"instructions other than branch instructions or function calls have "
242+
"exactly 1 successor",
243+
"found at goto program instruction number " +
244+
std::to_string(it->location_number));
248245

249246
for(const auto &cov : c_entry->second)
250247
{

0 commit comments

Comments
 (0)