Skip to content

Commit a7d15da

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 a7d15da

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <assert.h>
2+
3+
struct S2
4+
{
5+
signed char f0;
6+
unsigned short f1;
7+
};
8+
9+
union U10 {
10+
unsigned short f0;
11+
struct S2 f3;
12+
};
13+
14+
union U10 g_2110 = {.f0 = 53747};
15+
16+
int main()
17+
{
18+
assert(g_2110.f0 == 53747);
19+
20+
return 0;
21+
}
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)