[patch] Correctly align arrays of int64_t on 32 bit systems

Richard Smith richard at metafoo.co.uk
Wed Aug 7 17:05:09 PDT 2013


On Wed, Aug 7, 2013 at 5:04 PM, Richard Smith <richard at metafoo.co.uk> wrote:

> On Wed, Aug 7, 2013 at 2:58 PM, Rafael EspĂ­ndola <
> rafael.espindola at gmail.com> wrote:
>
>> > Should foo[n] really return different results depending on the value of
>> > n? That feels wrong to me.
>>
>> This is (and was) the odd case for x86_64. We accept but gcc rejects this
>>
>> -----------------------------
>> long long int foo[1];
>> long long int bar[2];
>>
>> static_assert(alignof(foo) == 8, "foo");
>> static_assert(alignof(bar) == 16, "bar");
>> -----------------------------
>>
>> Richard, gcc is correct in here, right?
>
>
> To quote Clang, 'alignof' applied to an expression is a GNU extension.
> Thus we should presumably do what GCC does -- C++ doesn't have a notion of
> the alignment of a declaration as distinct from the alignment of its type.
>

OK, so that's not strictly-speaking true, but it doesn't have a notion of
the alignment being increased because all globals happen to be 16-byte
aligned on the target system.


>
>
>> If so I can try to code a
>> patch replacing RefAsPointee with a more generic ForAlignof.
>>
>> Cheers,
>> Rafael
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130807/5df4029e/attachment.html>


More information about the cfe-commits mailing list