<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54623>54623</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
_Atomic structure assignment in C++ mode is broken
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++,
rejects-valid,
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
The following code should compile in C++ mode same as it compiles in C mode:
```
_Atomic struct x { int x; } x1;
int main() {
_Atomic struct x y1 = x1; // error: cannot initialize a variable of type '_Atomic(struct x)' with an lvalue of type '_Atomic(struct x)'
struct x y2 = x1; // error: no viable conversion from '_Atomic(struct x)' to 'struct x'
}
```
We give two different errors in C++ mode for this code but it is valid C code.
While working on this, we should also consider what the direct list initialization behavior should be:
```
_Atomic struct x { int x; } x1;
int main() {
_Atomic struct x y3{x1}; // error: illegal initializer type '_Atomic(struct x)'
struct x y4{x1}; // error: cannot initialize a member subobject of type 'int' with an lvalue of type '_Atomic(struct x)'
}
```
At the very least, the diagnostics for this case should be improved, but I am not certain why we would reject this code.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVMFu2zAM_Rr7QjRw5LitDz4kLQrsPqDHgbJpW6ssBZLsNPv6UXbSZFtXDNthgGCLokg-8j1b2uZYfe4JWqu1PSjTQW0bAt_bUTe8H_ZKEygDD4nY8YJhduNAgB5UOF_x853Zm-TbJHtMsm1ym53WbH7ZBjuoGnxwYx3gFZK7HUfxLsl3bDzC65p3p9j5Gb0DKpOI-0SUMWA5B_gl2XENSX5KAYl44gXknHUMB2o0xgYupoJCrb4xeJjQKZTcnG0hHPfEQXenrFzunJfL8jkcVOgBDegJ9fhHIWegF4DiA4DGwrSgqa2ZyHllDbTODh-iCja6L4enojzKdwl4JujURBAOFhrVtuSI5ztj8L9Q3FoHoVd-0YMcQySbTR6AapjpeLy65uq5j0o5WPcSVcTwY3QiHuDwJifU3sYGvWrIwaHHwJeIsTjiBrTyVxRhiCOQ1OOkGMopg_xf6srZywl4su-wp7SmDvWVvtxf6GPzUYn3FDzQILmSH6WVX-MEr2TJvf2Lbn8noe3CGCv0CJrQh0jwwiF2xvqgan8lHfR0YQ7UsHd2oibGREF9AhwgdlWTC8wDK-IY1XKYAxzNPb1pcJU2Vd6UeYlpUEFT9SNJo4t_JK86M0RV_yxnTiKdfSGTjk5XfQh7H5U0T7njIY1yxX8yNrSezq8bhhsxsKm8H4nV_FRsbkWe9tW6qcsNGw2KNsdMYiZkU6xz2ZYFbjJKNUrSvkoKxiDqBQrvYu_8WprzN_PXdDmuNZqOcV1NMzqLx1RVIhMiy0W5vs9KUaxk3RZlKzZZU2dtIUXCRVnMehWRr6zrUlfNTcix8-yMX5e_OJdREc0AOT-Oobeu2qKzZodaD2jSuelq7vg7ib3xBA">