[cfe-dev] c++11's alignas() ignored inside #pragma pack
Richard Smith
richard at metafoo.co.uk
Tue Jul 22 15:58:42 PDT 2014
On Tue, Jul 22, 2014 at 1:03 PM, jahanian <fjahanian at apple.com> wrote:
> Implementation says that it is intentional:
>
> // The maximum field alignment overrides the aligned attribute.
> if (!MaxFieldAlignment.isZero()) {
> FieldAlign = std::min(FieldAlign, MaxFieldAlignment);
> UnpackedFieldAlign = std::min(UnpackedFieldAlign, MaxFieldAlignment);
> }
> - Fariborz
>
I too find this very surprising. Does this match GCC / MSVC behavior for
#pragma pack? I don't think it matches __attribute__((packed)).
> On Jul 22, 2014, at 11:04 AM, jahanian <fjahanian at apple.com> wrote:
>
> This test shows that alignas() is ignored when used with #pragma.
> Is this intentional behavior?
>
> #pragma pack(push, 1)
> struct S1 { char a; short b; double c; alignas(32) double d; char e;
> double f; };
> #pragma pack(pop)
>
> int main()
> {
> return sizeof(struct S1);
> }
>
> - Thanks, Fariborz
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140722/a92a0f24/attachment.html>
More information about the cfe-dev
mailing list