Skip to content

Commit 4338b33

Browse files
author
Daniel Kroening
committed
fix anonymous struct member initialization
The C front-end needs to ignore the unnamed bit-field during struct initialization; issue #3709.
1 parent 4714c4e commit 4338b33

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

regression/cbmc/Struct_Initialization1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$

src/ansi-c/c_typecheck_initializer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,10 +663,15 @@ void c_typecheck_baset::increment_designator(designatort &designator)
663663
assert(components.size()==entry.size);
664664

665665
// we skip over any padding or code
666-
while(entry.index<entry.size &&
666+
// we also skip over anonymous members
667+
while(entry.index < entry.size &&
667668
(components[entry.index].get_is_padding() ||
668-
components[entry.index].type().id()==ID_code))
669+
(components[entry.index].get_anonymous() &&
670+
components[entry.index].type().id() != ID_struct_tag) ||
671+
components[entry.index].type().id() == ID_code))
672+
{
669673
entry.index++;
674+
}
670675

671676
if(entry.index<entry.size)
672677
entry.subtype=components[entry.index].type();

0 commit comments

Comments
 (0)