<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60513>60513</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] using in combination of `__declspec(align())` and `static_assert` doesn't work as expected.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tru
</td>
</tr>
</table>
<pre>
This code:
```
struct Test
{
int a;
};
using TestUsing = __declspec(align(16)) const Test; // Current way
typedef __declspec(align(16)) const Test TestTypeDef; // Old way
static_assert(alignof(Test) == 4, "Not 4"); // Ok.
static_assert(alignof(TestTypeDef) == 16, "Not 16 (typedef)"); // Ok.
static_assert(alignof(TestUsing) == 16, "Not 16 (using)"); // NOT OK!! This asserts in Clang.
```
will fail with:
```
x86-64 clang (trunk) - cached
<source>:11:1: error: static assertion failed due to requirement 'alignof(const Test) == 16': Not 16 (using)
static_assert(alignof(TestUsing) == 16, "Not 16 (using)"); // NOT OK!! This asserts in Clang.
^ ~~~~~~~~~~~~~~~~~~~~~~~~
<source>:11:34: note: expression evaluates to '4 == 16'
static_assert(alignof(TestUsing) == 16, "Not 16 (using)"); // NOT OK!! This asserts in Clang.
~~~~~~~~~~~~~~~~~~~^~~~~
1 error generated.
```
But works in MSVC as seen on godbolt: https://godbolt.org/z/hfnoeb6W9
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU9v47YT_TSjyyAG_1iyfdAhtuPLD7_NoWl7DGhyZLORSZekNkkP_ewFKblO2myw6GkFYTwCpTfz3jyTKkZ7cEQt1Guot5Ua0tGHNoWh2nvz2j4cbUTtDYG8BbYFdokNm-7yGFMYdMIHimlaX6zHBBHRuoQK5PqytL3mJQ7RukP5-OeSgdzi46Mh3cczaRBL1duDA7HkDYgViBVq7-JUTq4RxA7EDjdDCOQSPqvXETe9nslQ991YJTy8nmlL3Rvc-95cMS98VbL6UcVIIV1AfQdiWXoSq8wh05iD2CAI8cWnnItc8w3y0-x78C4tXWFz83_j8gZBLCeyhdR_K1PE_7zIML3yrxJf7h_w_n8gOAiOxTRjkYjW4aZX7jD70DhjfLZ9j52yPT7bdPzcai_L5qaZo86YhXcY3FPu-ga10kcy01dyE_0QNIG8A3nLeQ4gb5FC8CEnoxhTn9a70gAZNANh8hjo98EGOmVHgVhcpXrjvfdaLTLqB1r9MNLXd_jnN65viybnmZbziYp6L-dAMWa56KvqB5UoZrVALObvtfhRWOO76yPq9d1VAT76Aw_kKKhE5jPbroeEzz48lZr__-mXDaqIkcihd3jwZu_7lEU7pnSO2dWl9Wlh5sMBxO4PELtj5zztm19Xb8Er00qzkitVUcubRT2XYil4dWw7VnNTd9LUkmpmVmREo43hy0bWXd2xyraCCckEk3zOGJ_PuObEtekaRntSvIE5o5Oy_azvv55yH5WNcaC2YTWXVa_21MdyIAihQazLLUBs8nNWFuRtF7xL5ExeqLdVaDPUzX44RJiz3sYUr-DJpr4cMGUsUG9x3PCtQ-1Pe-tU-fv5DqFhH-7V404NDUPlTH7rva8ahsZTdCAW40DyHOjlTDoPsBpC3_5jBDYdh_1M-xOIXe5z-rk5B_8b6QRiVxSJIHZFlL8CAAD__2lxHBI">