[cfe-dev] c++11's alignas() ignored inside #pragma pack

jahanian fjahanian at apple.com
Wed Jul 23 09:45:30 PDT 2014


On Jul 22, 2014, at 5:26 PM, Reid Kleckner <rnk at google.com> wrote:

> 
> 
> Presumably they handle alignas the same way they handle __declspec(align(N)), which overrides packing.  MSVC appears to have two notions of alignment, required and advisory, while the C++ standard, Clang, and GCC only have one.  One way to observe this is to see that they will align an int64 to 8 bytes in a struct, but they will not realign the stack to 8 bytes when that struct is stack allocated.
> 
> Also, Clang does respect alignas in this case when targeting the Microsoft C++ ABI.

I tried the test case with these options for MS ABI:

clang -cc1 -triple x86_64-windows-msvc -std=c++11 -S t.cpp

Assembly indicates that it does not seem to respect alignas. Should I be using other options?

main:
	movl	$28, %eax
	movl	$0, -4(%rsp)
	retq


- Fariborz


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140723/4657a03c/attachment.html>


More information about the cfe-dev mailing list