This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [libstdc++/65033] Give alignment info to libatomic
- From: Richard Henderson <rth at redhat dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, Andrew MacLeod <amacleod at redhat dot com>
- Date: Wed, 25 Mar 2015 12:04:33 -0700
- Subject: Re: [libstdc++/65033] Give alignment info to libatomic
- Authentication-results: sourceware.org; auth=none
- References: <54DD19B7 dot 6060401 at redhat dot com> <20150218121512 dot GI3360 at redhat dot com> <20150325162244 dot GF9755 at redhat dot com> <5513003D dot 3040107 at redhat dot com> <20150325184913 dot GH9755 at redhat dot com>
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)
r~