<div dir="ltr"><div>Hi,</div><div><br></div><div>I'm not sure if this has been discussed before. With alignas, on clang, if the natural type of the data has a larger alignment than what I requested with alignas, I get a compile error if the specified alignment is smaller than what would be the natural alignment of the type.</div><div><br></div><div>Example:<br></div><br>struct alignas(2) XX {<br>  void* p;<br>};<br><br>gives: error: requested alignment is less than minimum alignment of 8 for type 'XX'<br><br>Happens on both MacOS and Linux clang build. Does not happen with GCC. Does not happen with ATTRIBUTE_ALIGN(2).<br><br>Is this a clang bug? The standard [1] says:<br><br>"The object or the type declared by such a declaration will have its alignment requirement equal to the strictest (largest) non-zero expression of all alignas specifiers used in the declaration, unless it would weaken the natural alignment of the type. "<br><div><br></div><div>That reads to me like gcc is correct.<br></div><div><br></div>This is a bit of a drawback compared to ATTRIBUTE_ALIGN, especially if coding for different 32-bit and 64-bit platforms.<br><br>[1] <a href="https://en.cppreference.com/w/cpp/language/alignas">https://en.cppreference.com/w/cpp/language/alignas</a></div>