<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jul 23, 2014, at 9:45 AM, jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jul 22, 2014, at 5:26 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><br><div><br></div><div>
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.</div>
<div><br></div><div>Also, Clang does respect alignas in this case when targeting the Microsoft C++ ABI.</div></div></div></div>
</blockquote><br></div><div>I tried the test case with these options for MS ABI:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">clang -cc1 -triple x86_64-windows-msvc -std=c++11 -S t.cpp</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">Assembly indicates that it does not seem to respect alignas. Should I be using other options?</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><div style="margin: 0px;">main:</div><div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">      </span>movl<span class="Apple-tab-span" style="white-space:pre">        </span>$28, %eax</div><div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">     </span>movl<span class="Apple-tab-span" style="white-space:pre">        </span>$0, -4(%rsp)</div><div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre">  </span>retq</div><div><br></div><div><br></div></div></div></div></blockquote><div><br></div>Oops. I was using an old clang. Sorry for the noise.</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">main:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">       </span>movl<span class="Apple-tab-span" style="white-space:pre">        </span>$64, %eax</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre">        </span>retq</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><div>- Fariborz</div><div><br></div></div></div><br></div></blockquote></div><br></body></html>