https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80441
Bug ID: 80441
Summary: Spurious Warnings with -Wmissing-field-initializers
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: Vaelatern at voidlinux dot eu
Target Milestone: ---
Created attachment 41204
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41204&action=edit
Working testcase to demonstrate, with debug information in a comment.
According to my understanding of the spec, the struct initialization in the
following minimal test case should have no problems:
[code]
#include <assert.h>
struct testcase {
char version;
unsigned int lookatme;
};
int
main (void)
{
struct testcase a = {0}; /* {.version == 0, .lookatme == 0} */
struct testcase b = {1}; /* {.version == 1, .lookatme == 0} */
struct testcase c = {.version = 1}; /* {.version == 1, .lookatme == 0}
*/
assert(a.version == 0);
assert(b.version == 1);
assert(c.version == 1);
assert(a.lookatme == 0);
assert(b.lookatme == 0);
assert(c.lookatme == 0);
}
[/code]
but it does, with warnings to the tune of:
[code]
a.c: In function 'main':
a.c:12:9: warning: missing initializer for field 'lookatme' of 'struct
testcase' [-Wmissing-field-initializers]
struct testcase b = {1}; /* {.version == 1, .lookatme == 0} */
^~~~~~~~
a.c:5:15: note: 'lookatme' declared here
unsigned int lookatme;
^~~~~~~~
[/code]
Link to related git issue:
https://github.com/libgit2/libgit2/pull/4199
Minimal arguments to gcc to duplicate:
-Wmissing-field-initializers
Testcase attached, as well as debug information.
Believed to be related to:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36446