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++/72753] New: sole flexible array member in a typedef rejected


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

            Bug ID: 72753
           Summary: sole flexible array member in a typedef rejected
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The following program defines two structs whose only member is a flexible
array.  Such types are invalid and should be rejected.  G++ diagnoses the one
defined in the named struct but fails to diagnose the one in the unnamed
struct.

$ cat t.C && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S -Wall
-Wextra -Wpedantic t.C
struct A {
  int a[];
};

typedef struct {
  int a[];
} B;
t.C:2:9: error: flexible array member ‘A::a’ in an otherwise empty ‘struct A’
   int a[];
         ^
t.C:1:8: note: in the definition of ‘struct A’
 struct A {
        ^

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