[libstdc++/65033] Give alignment info to libatomic
Jonathan Wakely
jwakely@redhat.com
Thu Mar 26 13:21:00 GMT 2015
On 25/03/15 12:04 -0700, Richard Henderson wrote:
>On 03/25/2015 11:49 AM, Jonathan Wakely wrote:
>> On 25/03/15 11:36 -0700, Richard Henderson wrote:
>>> On 03/25/2015 09:22 AM, Jonathan Wakely wrote:
>> On 25/03/15 11:39 -0700, Richard Henderson wrote:
>>> On 03/25/2015 09:22 AM, Jonathan Wakely wrote:
>>>> +static_assert( alignof(std::atomic<twoints>) > alignof(int),
>>>> + "std::atomic not suitably aligned" );
>>>
>>> This is only true if int64_t has alignment larger than int32_t,
>>> which is unfortunately not always the case.
>>
>> Huh, didn't realise that. I could change the tests to check it's
>> alignof(std::int64_t) as the next assertion does, but is it safe to
>> assume that struct twoints { int a; int b; } is exactly 64 bits
>> everywhere?
>
>Certainly not. But if you're going to explicitly use int64_t elsewhere, you
>might as well explicitly use int32_t as well. Then I believe you can
>reasonably assert
>
> alignof(twoint32) == alignof(int64_t)
Yes, that makes sense, thanks. Here's what I plan to commit then.
This includes your fix to avoid decreasing alignment, but I didn't add
a test for that as I couldn't make it fail on any of the targets I
test on.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 3923 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20150326/d8503bcd/attachment.bin>
More information about the Libstdc++
mailing list