[Bug c/82283] Wrong warning with -Wmissing-field-initializers
yann at droneaud dot fr
gcc-bugzilla@gcc.gnu.org
Sat Feb 22 09:46:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82283
Yann Droneaud <yann at droneaud dot fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |yann at droneaud dot fr
--- Comment #3 from Yann Droneaud <yann at droneaud dot fr> ---
I'm experiencing the same issue in multiple cases, even with latest GCC trunk
(10.x).
I believe the following code is C99 conformant, but still trigger an unexpected
warning:
struct a {
int b;
};
struct c {
struct a d;
int e;
};
void f(struct c *);
void g(void) {
struct c h = {.d = (struct a){0}};
f(&h);
}
It produces the following warning:
<source>: In function 'g':
<source>:10:30: error: missing initializer for field 'e' of 'struct c'
[-Weror=missing-field-initializers]
10 | struct c h = {.d = (struct a){0}};
| ^
<source>:6:7: note: 'e' declared here
6 | int e;
| ^
cc1: all warnings being treated as errors
Compiler returned: 1
See https://godbolt.org/z/vQLYRX
More information about the Gcc-bugs
mailing list