[Bug c++/60323] incorrect usage of designated initializers with struct which includes flexible array

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 15 00:18:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60323

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-01-15
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1
      Known to fail|                            |4.9.3, 5.1.0, 6.0

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The ICE is gone with 4.9.3, 5.1.0, and trunk (6.0) but in C++ mode, all of them
reject the test case with the error below.  Since the test case is accepted in
C mode with a -Wmissing-braces warning for b, it seems that it should be
accepted in C++ mode as well.  Confirming on that basis but lowering Priority
to 4.

$ cat x.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc
-B/home/msebor/build/gcc-trunk-svn/gcc -S -Wall -Wextra -Wpedantic -xc++ x.c

struct A {
    char c;
    int data[];
};

struct A a = {.c = 1, .data = 1 };

x.c:7:14: warning: ISO C++ does not allow C99 designated initializers
[-Wpedantic]
 struct A a = {.c = 1, .data = 1};
              ^

x.c:7:21: warning: ISO C++ does not allow C99 designated initializers
[-Wpedantic]
 struct A a = {.c = 1, .data = 1};
                     ^

x.c:7:32: error: name ‘data’ used in a GNU-style designated initializer for an
array
 struct A a = {.c = 1, .data = 1};
                                ^

x.c:7:32: warning: initialization of a flexible array member [-Wpedantic]


More information about the Gcc-bugs mailing list