https://bugs.llvm.org/show_bug.cgi?id=40168
Bug ID: 40168
Summary: c11: Flexible array member in anonymous struct member
of another struct.
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
Test case (prog.c):
struct S
{
struct {
int x;
int a[];
};
int y;
};
int main()
{
}
Compilation command line:
clang prog.c -Wall -Wextra -std=c11 -pedantic-errors
Observed behaviour:
No errors outputed.
Expected behaviour:
An error message.
Structures with a flexible array member (in this case an anonymous structure
are not allowed as a member of another struct (in this case the struct S).
Another reason why an error message should be outputed is because the
flexible
array member of the anonymous struct member is also considered to be a
member of the struct S, but it is not the last member of that struct.
Reference to the c17 standard (the bugfix version of c11 standard):
6.7.2.1/3:
"A structure or union shall not contain a member with incomplete or
function
type (hence, a structure shall not contain an instance of itself, but may
contain a pointer to an instance of itself), except that
the last member of a structure with more than one named member may have
incomplete array type; such a structure (and any union containing, possibly
recursively, a member that is such a structure) shall not be a member of a
structure or an element of an array."
Note:
GCC outputs the expected error message.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs