Skip to content

Commit 7e02b53

Browse files
committed
Bitvector decoding of pointer-typed constants must use bvrep
The regression test demonstrated that decoding non-null pointer-typed constants were not correctly decoded to their integer representation.
1 parent 42b4740 commit 7e02b53

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
#include <assert.h>
2+
13
union U {
24
int *p;
35
unsigned long long p_int;
46
} u = {.p_int = 42};
57

68
int main()
79
{
10+
assert(u.p_int == 42);
811
}

regression/goto-instrument/dump-union/test.desc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ CORE
22
main.c
33
--dump-c
44
=(\(signed int \*\))?42
5+
VERIFICATION SUCCESSFUL
56
^EXIT=0$
67
^SIGNAL=0$
78
--

src/solvers/flattening/bv_pointers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr)
308308
encode(pointer_logic.get_null_object(), bv);
309309
else
310310
{
311-
mp_integer i=string2integer(id2string(value), 2);
311+
mp_integer i = bvrep2integer(value, bits, false);
312312
bv=bv_utils.build_constant(i, bits);
313313
}
314314

0 commit comments

Comments
 (0)