This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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]

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]