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

Nikola Smiljanic popizdeh at gmail.com
Tue Jul 22 17:11:34 PDT 2014


I just tried this and both gcc and clang return 28.


On Wed, Jul 23, 2014 at 9:10 AM, jahanian <fjahanian at apple.com> wrote:

>
> On Jul 22, 2014, at 3:58 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>
> 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)).
>
>
> I don’t have access to GCC. But MSVC’s behavior takes into account current
> pack setting and enforces  alignas() of the field.
>
>
> - Fariborz
>
>
>
>> 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
>>
>>
>
>
> _______________________________________________
> 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/20140723/ec6adfa2/attachment.html>


More information about the cfe-dev mailing list