<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 - error: initializer element is not a compile-time constant for valid code"
href="https://bugs.llvm.org/show_bug.cgi?id=48745">48745</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>error: initializer element is not a compile-time constant for valid code
</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>enhancement
</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>jstenglein@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>For the following code:
struct wss {
unsigned int count;
unsigned char _have_ct : 1 ;
};
struct capab {
struct wss _wss;
unsigned char _have_type;
};
struct node {
struct capab _capab;
};
struct node nd = {
._capab = {
._have_type = 1,
},
._capab._wss.count = 1, // ERROR!
};
Clang gives error:
clang -emit-llvm test.c -c
error: initializer element is not a compile-time constant
1 error generated.
Code appears to be valid according to struct initialization rules, and gcc
gives no error:
gcc -c test.c
<No error>
Also, error message doesn't show error location in the code.
Versions:
clang --version
clang version 12.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
f4f158b2f89e16ee7068d6292d2d46457d6932bb)
Target: x86_64-unknown-linux-gnu
Thread model: posix
gcc --version
gcc (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4)</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>