Skip to content

Commit ddbfd00

Browse files
committed
Rewrite unions such that all members are of the same size
In the C front-end, rewrite union components with types smaller than the union's size to anonymous structs. Each such struct contains the original union component plus padding. Assignments to union members thus always assign all bytes that make up the object representation of a union. The use of an anonymous struct ensures that member accesses can still be resolved. As this is a change in the semantics of goto programs, the goto binary version is incremented. rewrite_union is no longer necessary, but bugs (hidden by rewrite_union) in handling endianness in simplify_expr_member and convert_member surfaced and had to be fixed.
1 parent 8b02ecd commit ddbfd00

File tree

24 files changed

+326
-67
lines changed

24 files changed

+326
-67
lines changed

jbmc/src/jdiff/jdiff_parse_options.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Author: Peter Schrammel
4040
#include <goto-programs/remove_unused_functions.h>
4141
#include <goto-programs/remove_vector.h>
4242
#include <goto-programs/remove_virtual_functions.h>
43-
#include <goto-programs/rewrite_union.h>
4443
#include <goto-programs/set_properties.h>
4544
#include <goto-programs/show_properties.h>
4645
#include <goto-programs/string_abstraction.h>
@@ -296,7 +295,6 @@ bool jdiff_parse_optionst::process_goto_program(
296295
remove_returns(goto_model);
297296
remove_vector(goto_model);
298297
remove_complex(goto_model);
299-
rewrite_union(goto_model);
300298

301299
// add generic checks
302300
log.status() << "Generic Property Instrumentation" << messaget::eom;
693 Bytes
Binary file not shown.

regression/ansi-c/arch_flags_mcpu_bad/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This tests the -mcpu=cortex=a15 flag that should activate ARM-32 mode.
1111
The object file 'object.intel' was compiled from 'source.c' with goto-cc
1212
on a 64-bit platform:
1313

14-
goto-cc -c source.c
14+
goto-cc -c source.c -o object.intel
1515

1616
preproc.i is already pre-processed so that it can be linked in without
1717
needing to invoke a pre-processor from a cross-compile toolchain on your
687 Bytes
Binary file not shown.
Binary file not shown.

regression/ansi-c/arch_flags_mthumb_bad/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This tests the -mthumb flag that should activate ARM-32 mode. The object
1111
file 'object.intel' was compiled from 'source.c' with goto-cc on a
1212
64-bit platform:
1313

14-
goto-cc -c source.c
14+
goto-cc -c source.c -o object.intel
1515

1616
preproc.i is already pre-processed so that it can be linked in without
1717
needing to invoke a pre-processor from a cross-compile toolchain on your
686 Bytes
Binary file not shown.

regression/cbmc-library/float-nan-check/test.desc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
CORE
22
main.c
33
--nan-check
4-
\[main.NaN.1\] line \d+ NaN on \+ in byte_extract_little_endian\(c, (0|0l|0ll), float\) \+ myzero: SUCCESS
4+
\[main.NaN.1\] line \d+ NaN on \+ in c\.f \+ myzero: SUCCESS
55
\[main.NaN.2\] line \d+ NaN on / in myzero / myzero: FAILURE
66
\[main.NaN.3\] line \d+ NaN on / in \(float\)n / myinf: FAILURE
77
\[main.NaN.4\] line \d+ NaN on \* in myinf \* myzero: FAILURE
88
\[main.NaN.5\] line \d+ NaN on \+ in -myinf \+ myinf: FAILURE
99
\[main.NaN.6\] line \d+ NaN on - in myinf - myinf: FAILURE
1010
\[main.NaN.7\] line \d+ NaN on - in -myinf - -myinf: FAILURE
11-
\[main.NaN.8\] line \d+ NaN on \+ in byte_extract_little_endian\(c, (0|0l|0ll), float\) \+ byte_extract_little_endian\(c, (0|0l|0ll), float\): SUCCESS
12-
\[main.NaN.9\] line \d+ NaN on / in byte_extract_little_endian\(c, (0|0l|0ll), float\) / myzero: SUCCESS
11+
\[main.NaN.8\] line \d+ NaN on \+ in c\.f \+ c\.f: SUCCESS
12+
\[main.NaN.9\] line \d+ NaN on / in c\.f / myzero: SUCCESS
1313
\[main.NaN.10\] line \d+ NaN on \* in mynan \* mynan: SUCCESS
1414
\[main.NaN.11\] line \d+ NaN on \+ in mynan \+ mynan: SUCCESS
1515
\[main.NaN.12\] line \d+ NaN on - in mynan - mynan: SUCCESS
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE broken-smt-backend
2+
main.c
3+
--big-endian --no-simplify
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
--
10+
Although this test can now be fully solved via constant propagation and
11+
simplification, it should also succeed without simplification.

regression/cbmc/union7/test.desc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
CORE broken-smt-backend
1+
CORE
22
main.c
33
--big-endian
4+
Generated 3 VCC\(s\), 0 remaining after simplification
45
^EXIT=0$
56
^SIGNAL=0$
67
^VERIFICATION SUCCESSFUL$
78
--
89
^warning: ignoring
910
--
10-
This test reports a VERIFICATION ERROR when running with the SMT2 solver on
11-
Windows only.
11+
This test can now be fully solved via constant propagation and simplification.

0 commit comments

Comments
 (0)