public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95379] New: Don't warn about the universal zero initializer for a structure with the 'designated_init' attribute.
@ 2020-05-27 23:00 AsDaGo at posteo dot net
  2020-05-28  2:14 ` [Bug c/95379] " pinskia at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: AsDaGo at posteo dot net @ 2020-05-27 23:00 UTC (permalink / raw)
  To: gcc-bugs

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').

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-06-03 23:05 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 23:00 [Bug c/95379] New: Don't warn about the universal zero initializer for a structure with the 'designated_init' attribute AsDaGo at posteo dot net
2020-05-28  2:14 ` [Bug c/95379] " pinskia at gcc dot gnu.org
2020-05-28  2:16 ` pinskia at gcc dot gnu.org
2020-05-28  3:28 ` AsDaGo at posteo dot net
2020-05-28  7:41 ` rguenth at gcc dot gnu.org
2020-05-28  9:05 ` amonakov at gcc dot gnu.org
2020-05-28 13:13 ` tromey at gcc dot gnu.org
2020-05-28 15:36 ` AsDaGo at posteo dot net
2020-05-28 15:43 ` tromey at gcc dot gnu.org
2020-05-28 16:29 ` AsDaGo at posteo dot net
2020-05-28 19:25 ` luc.vanoostenryck at gmail dot com
2020-05-28 20:48 ` pinskia at gcc dot gnu.org
2020-05-28 21:02 ` luc.vanoostenryck at gmail dot com
2020-05-28 21:15 ` AsDaGo at posteo dot net
2020-05-28 22:51 ` AsDaGo at posteo dot net
2020-05-30 16:12 ` luc.vanoostenryck at gmail dot com
2020-05-31 17:57 ` AsDaGo at posteo dot net
2020-06-03 23:05 ` AsDaGo at posteo dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).