-Wmissing-field-initializers on C++ warns about missing initializer despite designated initializers present

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux