Skip to content

Commit bacfa27

Browse files
authored
Merge pull request #2114 from tautschnig/type-renaming
Ensure consistent type renaming of heap objects of dynamic size
2 parents 8b20ebb + b934aaf commit bacfa27

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <stdlib.h>
2+
#include <pthread.h>
3+
4+
_Bool set_done;
5+
int *ptr;
6+
7+
void *set_x(void *arg)
8+
{
9+
*(int *)arg = 10;
10+
set_done = 1;
11+
}
12+
13+
int main(int argc, char *argv[])
14+
{
15+
__CPROVER_assume(argc >= sizeof(int));
16+
ptr = malloc(argc);
17+
__CPROVER_ASYNC_1: set_x(ptr);
18+
__CPROVER_assume(set_done);
19+
assert(*ptr == 10);
20+
return 0;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/ansi-c/c_typecheck_type.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,9 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
581581
new_symbol.base_name=id2string(current_symbol.base_name)+suffix;
582582
new_symbol.type=size.type();
583583
new_symbol.type.set(ID_C_constant, true);
584-
new_symbol.is_type=false;
585-
new_symbol.is_static_lifetime=false;
586584
new_symbol.value=size;
587585
new_symbol.location=source_location;
586+
new_symbol.mode = mode;
588587

589588
symbol_table.add(new_symbol);
590589

src/goto-symex/symex_builtin_functions.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,15 @@ void goto_symext::symex_allocate(
138138
{
139139
exprt &size=to_array_type(object_type).size();
140140

141-
symbolt size_symbol;
141+
auxiliary_symbolt size_symbol;
142142

143143
size_symbol.base_name=
144144
"dynamic_object_size"+std::to_string(dynamic_counter);
145145
size_symbol.name="symex_dynamic::"+id2string(size_symbol.base_name);
146-
size_symbol.is_lvalue=true;
147146
size_symbol.type=tmp_size.type();
148147
size_symbol.mode = mode;
148+
size_symbol.type.set(ID_C_constant, true);
149+
size_symbol.value = size;
149150

150151
state.symbol_table.add(size_symbol);
151152

0 commit comments

Comments
 (0)