<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57436>57436</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Compiler regression in aggregate initializers with anonymous structs in unions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          flying-kestrel
      </td>
    </tr>
</table>

<pre>
    The following code is, to the best of my knowledge, standards-compliant C++, and compiles on clang 3.6 and all versions of g++ past 4.7.1 that I tried, but does not compile on clang 3.7 and later:

```c++
union flags {
    struct {
        unsigned a: 1;
        unsigned char : 0;
    };
};

template<typename T>
struct Test {
    Test(bool a) : f(flags {
       .a = a,
    }) {}

    flags f;
};

int main() {
    Test<int> ti(false);
    return 0;
}
```

Specifically, the error is: (see [godbolt](https://godbolt.org/z/Kzq9aaY5K))
```
<source>:20:15: note: in instantiation of member function 'Test<int>::Test' requested here
    Test<int> ti(false);
```

Note that if the rvalue `a` in the `flags{.a = a}` is replaced with a constant, this [compiles fine](https://godbolt.org/z/d56hvzKd9).

as such, my tentative hypothesis for cause of bug is that clang seems to be having trouble with finding the anonymous struct members inside the union during non-constant aggregate initialization.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE1v2zgQ_TXyhYigD1uWDjqkzgZYBNjL5rJHShpJbGnSJSkHzq_fN1ScxkW62AqUTXGGM4_vDaezw6V9nkmMVmv7oswkejuQUD4pDiJYEWDryAdhR3G8iG_GvmgaJmKzD9IM0g3-rrfHk1bSBHFIii9xHASMgg1KkxfWiF5LhC_TKlqk1uJMzitrPAef1o3iJJFsm-7THLllEH-K4BQNHLBbghgsghkbrpE_Bt7HwFoGckl5n2QPSXb9rbJ19G_w4upikFyMWk5eJPu3RYHHB7f04XaNn8V4NRkCeMQXeVL-yt7P0gn2yW58kv3D-_fNPP4GAokA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