[Bug c++/72754] New: pointer to an unnamed struct with a sole flexible array member accepted
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jul 29 21:45:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72754
Bug ID: 72754
Summary: pointer to an unnamed struct with a sole flexible
array member accepted
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 pointers to unnamed structs containing a
flexible array as their sole member. The structs are invalid and are rejected
with an error in C mode but silently accepted by G++.
$ cat t.C && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S -Wall
-Wextra -Wpedantic t.C
struct { int a[]; } *p;
struct S {
struct { int a[]; } *q;
};
t.C:1:22: warning: ‘p’ defined but not used [-Wunused-variable]
struct { int a[]; } *p;
^
Clang produces the following output:
t.C:1:14: warning: flexible array member 'a' in otherwise empty struct is a GNU
extension [-Wgnu-empty-struct]
struct { int a[]; } *p;
^
t.C:1:14: warning: flexible array members are a C99 feature [-Wc99-extensions]
t.C:4:16: warning: flexible array member 'a' in otherwise empty struct is a GNU
extension [-Wgnu-empty-struct]
struct { int a[]; } *q;
^
t.C:4:16: warning: flexible array members are a C99 feature [-Wc99-extensions]
t.C:1:22: warning: unused variable 'p' [-Wunused-variable]
struct { int a[]; } *p;
^
5 warnings generated.
More information about the Gcc-bugs
mailing list