[cfe-dev] 'struct' member alignment query

Tim Northover via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 9 07:08:17 PST 2017


On 9 February 2017 at 02:56, Martin J. O'Riordan via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Is this expected behaviour in 'clang', and if so, is there another way I can
> coerce the 'struct' member 'alignCheck2' onto another less constrained
> alignment boundary?

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:

typedef AlignCheck_t __attribute__((aligned(1))) UnAlignCheck_t;

then you can put that in the struct and it'll be laid out without any padding.

Tim.



More information about the cfe-dev mailing list