Skip to content

Commit 727aea1

Browse files
author
Daniel Kroening
authored
Merge pull request #694 from lucasccordeiro/fix-full-slice-03
consider array_copy expressions in the full-slice
2 parents 5ecb15e + e70aa7d commit 727aea1

File tree

6 files changed

+63
-0
lines changed

6 files changed

+63
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdlib.h>
2+
#include <assert.h>
3+
4+
int main()
5+
{
6+
int *ptr=malloc(sizeof(int));
7+
*ptr=42;
8+
ptr=realloc(ptr, 20);
9+
assert(*ptr==42);
10+
11+
int *ptr2=malloc(2*sizeof(int));
12+
*ptr2=42;
13+
*(ptr2+1)=42;
14+
ptr2=realloc(ptr2, 20);
15+
assert(*ptr2==42);
16+
assert(*(ptr2+1)==42);
17+
18+
return 0;
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
--full-slice --add-library
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <stdlib.h>
2+
#include <assert.h>
3+
4+
void foo(int argc)
5+
{
6+
void* x=0;
7+
8+
if(argc>3)
9+
x=malloc(4*sizeof(int));
10+
else
11+
x=malloc(3*sizeof(int));
12+
*(int*)x=42;
13+
14+
x=realloc(x, sizeof(int));
15+
16+
assert(*(int*)x==42);
17+
}
18+
19+
int main(int argc, char* argv[])
20+
{
21+
//__CPROVER_ASYNC_1:
22+
foo(argc);
23+
24+
return 0;
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
--full-slice --add-library
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$

src/goto-instrument/full_slicer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ static bool implicit(goto_programt::const_targett target)
337337
{
338338
// some variables are used during symbolic execution only
339339

340+
const irep_idt &statement=target->code.get_statement();
341+
if(statement==ID_array_copy)
342+
return true;
343+
340344
if(!target->is_assign())
341345
return false;
342346

src/pointer-analysis/value_set_fi.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,9 @@ void value_set_fit::apply_code(
17291729
else if(statement==ID_fence)
17301730
{
17311731
}
1732+
else if(statement==ID_array_copy)
1733+
{
1734+
}
17321735
else if(statement==ID_input || statement==ID_output)
17331736
{
17341737
// doesn't do anything

0 commit comments

Comments
 (0)