[llvm-bugs] [Bug 40168] New: c11: Flexible array member in anonymous struct member of another struct.
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Dec 27 13:11:20 PST 2018
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: unassignedclangbugs at nondot.org
Reporter: anders.granlund.0 at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181227/0c780f43/attachment.html>
More information about the llvm-bugs
mailing list