<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55963>55963</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
static fields in the extension ({ ... }) aren't initialized
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cagney
</td>
</tr>
</table>
<pre>
[root@freebsd root]# cc --version
FreeBSD clang version 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe)
Target: x86_64-unknown-freebsd13.0
Given:
```
typedef const struct where {
const char *func;
const char *file;
long line;
} *where_t;
```
and:
```
struct connection_filter {
/* filters */
enum connection_kind kind;
const char *name;
const struct id *this_id_eq; /* strict; not same_id() */
const struct id *that_id_eq; /* strict; not same_id() */
/* current result (can be safely deleted) */
struct connection *c;
/* internal: handle on next entry */
struct list_entry *internal;
/* internal: total matches so far */
unsigned count;
/* .where MUST BE LAST (See GCC [bug 102288](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=102288)) */
where_t where;
};
```
this:
```
+ struct connection_filter cq = {
+ .where = ({ \
+ static const struct where here = { \
+ .func = __func__, \
+ .file = __FILE__, \
+ .line = __LINE__, \
+ }; \
+ &here; \
+ }),
+ };
+ dbg("FOR_EACH_CONNECTION_... in %s %s %ld",
+ cq.where->func, cq.where->file, cq.where->line);
```
is mis-compiled. It prints NULL, NULL, 0 when it should print __func__, __FILE__, __LINE__.
Note:
- only the field .where is initialized, if a second field is initialized to something non-zero then things seem to compile correctly
- I could include the assembler but I'm not sure of the point - the compiler lost track of values in a static structure leaving the fields unset
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVl1vozoQ_TXkxQIRCIQ-5KFNmr2RelPptvuMjD0Ebx2TYtNu-uvvGJOvps1-osgQ-_jM2J4546Lm24mX3DR1bbxRWDYAheak-5vMvCgmjBHff4FGi1p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