<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - c11: Flexible array member in anonymous struct member of another struct."
href="https://bugs.llvm.org/show_bug.cgi?id=40168">40168</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>c11: Flexible array member in anonymous struct member of another struct.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>anders.granlund.0@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>