https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95379
Bug ID: 95379
Summary: Don't warn about the universal zero initializer for a
structure with the 'designated_init' attribute.
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: AsDaGo at posteo dot net
Target Milestone: ---
Created attachment 48623
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48623&action=edit
A small program illustrating the bug
When the 'designated_init' attribute is used on a structure type, GCC warns
when an instance of that structure is initialized with '{ 0 }'. I think GCC
should make an exception for this, since '{ 0 }' is often used to initialize
all fields of a structure to 0, and it does not depend on the internal
structure of the structure type.
If '{ }' is used to initialize the structure, GCC does not warn. However,
although '{ }' seems to initialize the structure to zero in GCC, I'm not sure
if it's as portable as '{ 0 }' (and it's less readable, IMO). I think '{ }' is
part of the C++ standard; does anyone know if it's part of C too?
See the attached test program (compile with 'gcc -o test test.c').