<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Book Antiqua";
        panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Book Antiqua",serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Book Antiqua",serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-IE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'>I can verify that this does work though, even if I don’t understand the semantics or rationale.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'>            MartinO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#002060;mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Martin J. O'Riordan [mailto:martin.oriordan@movidius.com] <br><b>Sent:</b> 09 February 2017 19:55<br><b>To:</b> 'Richard Smith' <richard@metafoo.co.uk><br><b>Cc:</b> 'Clang Dev' <cfe-dev@lists.llvm.org>; 'Tim Northover' <t.p.northover@gmail.com><br><b>Subject:</b> RE: [cfe-dev] 'struct' member alignment query<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>Hi Richard,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>How does ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>packed</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ work in this context?  I thought ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>packed</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ would cause the whole aggregate to eliminate padding, rather than just changing the alignment requirements of a single member.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>What I want is that the outer aggregate is aligned in the normal way according the maximum alignment requirements of its members.  However, I want to also have a member which itself is an aggregate with its usual internal padding retained, but changed its alignment constraint (essentially lying) within the context of the enclosing aggregate.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>Would ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>packed</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ not just unilaterally remove the padding?<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>For example (assuming </span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>char</span><span style='font-family:"Book Antiqua",serif;color:black;mso-fareast-language:EN-US'> </span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>is 1-byte and </span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>int</span><span style='font-family:"Book Antiqua",serif;color:black;mso-fareast-language:EN-US'> </span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>is 4, and natural alignment):<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>struct Inner {<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>  char c;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>  int  i;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>};<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>Inner x;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>I can reasonably assume on a naturally aligned system that the following would hold true (undefined ISO behaviour ignored regarding address arithmetic - assume a simple conventional 32-bit Von Neumann address space):<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>sizeof(Inner) == 8<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>((unsigned)&x & 7) == 0<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>((unsigned)&x.i - (unsigned)&x.c) == 4<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>offsetof(Outer, c) == 0<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>offsetof(Outer, i) == 4<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>Now what I want to do is:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>struct Outer {<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>  char aa;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>  int  bb;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>  char cc;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>  [magic attribute] Inner xx;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>  char dd;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>  int  ee;<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>};<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>Outer y;<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>Such that:<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>sizeof(Outer) == 24<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>((unsigned)&y & 7) == 0<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>((unsigned)&y.xx.i - (unsigned)&y.xx.c) == 4<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>((unsigned)&y.xx.i - (unsigned)&y) == 13<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>offsetof(Inner, bb) == 4<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>offsetof(Inner, cc) == 8<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>offsetof(Inner, xx) == 9<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>offsetof(Inner, dd) == 17<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>offsetof(Inner, ee) == 20<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>so padding is still present within the layout of ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>xx</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, and also as normal for the member alignment of ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>aa</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>bb</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>cc</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>dd</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ and ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>ee</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ within ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>Outer</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, but not for ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>xx</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>This is useful when overlaying structures on registers in a memory-mapped device which can have weird arrangements, and avoid the need for dirty little macro arithmetic tricks which are sadly very common in embedded systems device driver code.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>So forgive me if I am misunderstanding ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>packed</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ (and I probably am), but will this not cause the members of ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>Inner</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ as a member of ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>Outer</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ to become packed (</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>(unsigned)&i == (unsigned)&c + 1</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>), or does it simply loosen the alignment constraint within the members of ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>Outer</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ to achieve what I intend?  I usually interpret ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>packed</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ as all-or-nothing.  So if I replace ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>[magic attribute]</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ with ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>__attribute__((packed))</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, this will achieve the effect I require?  What if I want to force alignment of ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>xx</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ to 2-bytes instead of 1?<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>The only reasonably portable way I know of doing this kind of thing, is to always pack structures, and to explicitly provide the dummy padding bytes (including bitfield alignment magic such as ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>int:0;</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’), but while these are mostly-portable, they are not absolute in the context of a specific implementation - which is where ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>__attribute__((aligned(x)))</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ is necessary.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>In any case, the incongruity of using ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>aligned</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ in a ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>typedef</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ versus explicitly on the member is quite unintuitive, though I fully understand the need for CLang to maintain compatibility with GCC in this regard.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>            MartinO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> <a href="mailto:metafoo@gmail.com">metafoo@gmail.com</a> [<a href="mailto:metafoo@gmail.com">mailto:metafoo@gmail.com</a>] <b>On Behalf Of </b>Richard Smith<br><b>Sent:</b> 09 February 2017 18:03<br><b>To:</b> Martin J. O'Riordan <<a href="mailto:Martin.ORiordan@movidius.com">Martin.ORiordan@movidius.com</a>><br><b>Cc:</b> Clang Dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>>; Tim Northover <<a href="mailto:t.p.northover@gmail.com">t.p.northover@gmail.com</a>><br><b>Subject:</b> Re: [cfe-dev] 'struct' member alignment query<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>The "right" way to get this effect is to use __attribute__((packed)) on the field.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On 9 Feb 2017 9:33 am, "Martin J. O'Riordan via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><p class=MsoNormal>Wow!  Thanks for the response, that worked perfectly.<br><br>I never would have expected that the indirect 'typedef' approach would behave any differently to the more direct annotation!  I feel that this is probably an unintended GCC behaviour/bug, though CLang is 100% right to maintain compatibility with GCC.<br><br>But it solved my problem, thanks very much,<br><br>        MartinO<o:p></o:p></p><div><p class=MsoNormal><br>-----Original Message-----<br>From: Tim Northover [mailto:<a href="mailto:t.p.northover@gmail.com">t.p.northover@gmail.com</a>]<br>Sent: 09 February 2017 15:08<br>To: Martin J. O'Riordan <<a href="mailto:Martin.ORiordan@movidius.com">Martin.ORiordan@movidius.com</a>><br>Cc: cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>Subject: Re: [cfe-dev] 'struct' member alignment query<br><br>On 9 February 2017 at 02:56, Martin J. O'Riordan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>> Is this expected behaviour in 'clang', and if so, is there another way<br>> I can coerce the 'struct' member 'alignCheck2' onto another less<br>> constrained alignment boundary?<br><br>It's expected, but I think only because of GCC compatibility because it's really not obvious behaviour. The workaround, which still mystifies me, is to go via a typedef:<br><br>typedef AlignCheck_t __attribute__((aligned(1))) UnAlignCheck_t;<br><br>then you can put that in the struct and it'll be laid out without any padding.<br><br>Tim.<br><br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><o:p></o:p></p></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>