Open
Description
CBMC version: 5.43.0
Operating system: Ubuntu 20.04.4 LTS
Exact command line resulting in the issue:
goto-cc test.c -o test
goto-instrument test --constant-propagator test
goto-instrument test --dump-c test1.c
What happened instead:
test.c :
#include <assert.h>
int ab, bc;
int f(int x) {
ab = 1 + 1 + 1 + 1;
bc = ab + x;
return ab + bc;
}
int main() {
int a;
a = -4;
int b;
b = nondet();
a = f(a);
assert(!(0 <= a && a < 5 && 0 <= b && b < 5));
}
and test1.c:
#include <assert.h>
// f
// file test.c line 5
signed int f(signed int x);
// nondet
// file test.c line 15 function main
signed int nondet(void);
// ab
// file test.c line 3
signed int ab;
// bc
// file test.c line 3
signed int bc;
// f
// file test.c line 5
signed int f(signed int x)
{
ab = 4;
bc = 0;
return ab + bc;
}
// main
// file test.c line 11
signed int main()
{
signed int a=-4;
signed int b=nondet();
a=f(-4);
/* assertion !(0 <= a && a < 5 && 0 <= b && b < 5) */
assert(1);
}
The "assert(1);" is invalid.
and another bug case with a recursive function: https://gitlab.com/sosy-lab/benchmarking/sv-benchmarks/-/blob/main/c/recursive-simple/fibo_25-1.c
goto-cc sv-benchmarks/c/recursive-simple/fibo_25-1.c -o fibo
goto-instrument fibo --constant-propagator fibo
goto-instrument fibo --dump-c fibo.c
the fibo.c:
#include <assert.h>
#include <stdlib.h>
// fibo
// file data/cbmc/sv-benchmarks/c/recursive-simple/fibo_25-1.c line 7
signed int fibo(signed int n);
// reach_error
// file data/cbmc/sv-benchmarks/c/recursive-simple/fibo_25-1.c line 4
void reach_error();
// fibo
// file data/cbmc/sv-benchmarks/c/recursive-simple/fibo_25-1.c line 7
signed int fibo(signed int n)
{
goto __CPROVER_DUMP_L1;
return 0;
__CPROVER_DUMP_L1:
;
goto __CPROVER_DUMP_L2;
return 1;
__CPROVER_DUMP_L2:
;
signed int return_value_fibo=fibo(24);
signed int return_value_fibo$0=fibo(n - 2);
return return_value_fibo + return_value_fibo$0;
}
// main
// file data/cbmc/sv-benchmarks/c/recursive-simple/fibo_25-1.c line 25
signed int main(void)
{
signed int x=25;
signed int result;
signed int return_value_fibo=fibo(25);
result = return_value_fibo;
if(result == 75025)
{
ERROR:
;
reach_error();
abort();
}
return 0;
}
// reach_error
// file data/cbmc/sv-benchmarks/c/recursive-simple/fibo_25-1.c line 4
void reach_error()
{
/* assertion 0 */
assert(0);
}
"signed int return_value_fibo=fibo(24);" : In this case, you shouldn't have propagate the constant.
Metadata
Metadata
Assignees
Labels
No labels