Skip to content

Commit c67b5ca

Browse files
committed
Partly revert "Simplify initializer to remove byte_update"
This reverts commit ac31213, which can break dump-c output: the simplified expression may have padding initialised to non-zero values. This works fine for any analysis, but breaks dump-c as padding is not included in the output. Found via tests generated CSmith, a minimised version of which is included as a regression test.
1 parent 5efb6ad commit c67b5ca

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <assert.h>
2+
3+
struct S2
4+
{
5+
signed char f0;
6+
unsigned short f1;
7+
};
8+
9+
union U10
10+
{
11+
unsigned short f0;
12+
struct S2 f3;
13+
};
14+
15+
union U10 g_2110={ .f0=53747 };
16+
17+
int main()
18+
{
19+
assert(g_2110.f0 == 53747);
20+
21+
return 0;
22+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
--dump-c
4+
VERIFICATION SUCCESSFUL
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
--
10+
This test must verify successfully also for the output generated using dump-c,
11+
which previously did not correctly represent the union initializer.

src/ansi-c/c_typecheck_initializer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ exprt c_typecheck_baset::do_initializer_rec(
7272
}
7373

7474
if(value.id()==ID_initializer_list)
75-
{
76-
return simplify_expr(
77-
do_initializer_list(value, type, force_constant), *this);
78-
}
75+
return do_initializer_list(value, type, force_constant);
7976

8077
if(
8178
value.id() == ID_array && value.get_bool(ID_C_string_constant) &&

0 commit comments

Comments
 (0)