[Bug c/71939] New: sole flexible array member in an anonymous structure rejected
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 20 02:56:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71939
Bug ID: 71939
Summary: sole flexible array member in an anonymous structure
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: ---
While testing a fix for bug 71912 and comparing the C++ front end results to
those of the C front end I came across the following test case that's accepted
in C++ but rejected in C. By my reading of C11 the test case is valid because
"members of an anonymous structure or union are considered to be members of the
containing structure or union" and so struct S should be treated as if it had
been defined as:
struct S {
int i;
int a[];
};
I note that both Clang and EDG eccp 4.11 also reject the code in C, Clang
accepts in C++ mode with -Wflexible-array-extensions.
$ cat xyz.c && /build/gcc-71912/gcc/xgcc -B /build/gcc-71912/gcc -Wall -Wextra
-Wpedantic xyz.c
struct S {
int i;
struct { int a[]; };
};
xyz.c:3:16: error: flexible array member in otherwise empty struct
struct { int a[]; };
^
More information about the Gcc-bugs
mailing list