* -Wmissing-field-initializers on C++ warns about missing initializer despite designated initializers present
@ 2024-01-10 4:31 Jakob Hasse
0 siblings, 0 replies; only message in thread
From: Jakob Hasse @ 2024-01-10 4:31 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 979 bytes --]
Hello, I'm trying to compile the following C++ code with -Wmissing-field-initializers and it triggers a warning:
struct S { int f, g, h; };
int main(int argc, char** argv) {
struct S x = { .f = 3, .g = 4 };
}
$ gcc -Wmissing-field-initializers test.cpp -o test
test.cpp: In function ‘int main(int, char**)’:
test.cpp:4:35: warning: missing initializer for member ‘S::h’ [-Wmissing-field-initializers]
4 | struct S x = { .f = 3, .g = 4 };
| ^
However, the man page explicitly says: "This option does not warn about designated initializers". In fact, the example is basically the example given in the man page which is not supposed to trigger a warning. If I compile the same code as C code, no warning is triggered. The man page does not mention any difference in C++, regarding designated initializers. Is there something else I did not understand correctly or is it an issue in GCC?
Kind Regards,
Jakob
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-10 4:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 4:31 -Wmissing-field-initializers on C++ warns about missing initializer despite designated initializers present Jakob Hasse
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).