This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [libstdc++/65033] Give alignment info to libatomic
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>, libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 7 Apr 2015 23:58:28 -0400 (EDT)
- Subject: Re: [libstdc++/65033] Give alignment info to libatomic
- Authentication-results: sourceware.org; auth=none
- References: <54DD19B7 dot 6060401 at redhat dot com> <alpine dot BSF dot 2 dot 02 dot 1504022240580 dot 40679 at arjuna dot pair dot com> <alpine dot BSF dot 2 dot 02 dot 1504030518160 dot 69548 at arjuna dot pair dot com> <20150403141333 dot GY9755 at redhat dot com> <alpine dot BSF dot 2 dot 02 dot 1504052052110 dot 29977 at arjuna dot pair dot com> <20150407094458 dot GA9755 at redhat dot com> <alpine dot BSF dot 2 dot 02 dot 1504070641560 dot 16304 at arjuna dot pair dot com> <20150407131252 dot GB9755 at redhat dot com> <alpine dot BSF dot 2 dot 02 dot 1504070922410 dot 45243 at arjuna dot pair dot com> <20150407150617 dot GH9755 at redhat dot com>
On Tue, 7 Apr 2015, Jonathan Wakely wrote:
> The docs are clear that alignof(s.x) is not related to its position in
> struct SoSo: https://gcc.gnu.org/onlinedocs/gcc/Alignment.html
>
> I'm not going to worry about that behaviour changing.
'kthen thanks, quite clear; I should have checked that myself.
BTW; I hope nobody uses alignof the atomic types for e.g. manual
memory management, because any inner alignment of the atomic
payload isn't exposed; they get the default alignment:
#include <atomic>
#include <iostream>
using std::cout;
using std::endl;
std::atomic_int ai;
std::atomic_llong all;
std::atomic_intmax_t aim;
int main(void)
{
cout << "alignof(ai): " << alignof(ai) << " .is_lock_free(): " << ai.is_lock_free() << endl;
}
alignof(ai): 1 .is_lock_free(): 1
I'd expect
alignof(ai): 4 .is_lock_free(): 1
No... wait, that's because atomic_base.h doesn't have the
natural-alignment fix, so it's still broken for
less-than-natural-alignment targets. But will be fixed?
brgds, H-P