public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cagney at sourceware dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/102288] New: using .field = ({ static struct a a = {... }; &a; }) requires following field to be initialized Date: Sat, 11 Sep 2021 14:38:31 +0000 [thread overview] Message-ID: <bug-102288-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102288 Bug ID: 102288 Summary: using .field = ({ static struct a a = {... }; &a; }) requires following field to be initialized Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: cagney at sourceware dot org Target Milestone: --- Created attachment 51438 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51438&action=edit more examples (hopefully the version used for the above_ gcc --version gcc (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1) Note the use of ({}) and static when initializing the field BA: 1 struct a { 2 unsigned a1; 3 }; 4 5 #define A ({ static const struct a a = { .a1 = 1, }; &a; }) 6 7 struct ba01 { 8 const struct a *ba; 9 int b0; 10 int b1; 11 }; 12 13 struct b0a1 { 14 int b0; 15 const struct a *ba; 16 int b1; 17 }; 18 19 struct b01a { 20 int b0; 21 int b1; 22 const struct a *ba; 23 }; 29 // complains that next field (.b0) isn't initialized 30 31 { 32 struct ba01 ba01 = { 33 .ba = A, 34 // .b0 = 0, 35 // .b1 = 1, 36 }; 37 use(&ba01); 38 } gcc -Wall -Wextra -c unused.c unused.c: In function ‘main’: unused.c:36:5: warning: missing initializer for field ‘b0’ of ‘struct ba01’ [-Wmissing-field-initializers] 36 | }; | ^ unused.c:9:7: note: ‘b0’ declared here 9 | int b0; | ^~ - just the next field needs to be initialized (not all) - so, putting BA at the end avoids the problem - so to does not using ({})
reply other threads:[~2021-09-11 14:38 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-102288-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).