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: Jonathan Wakely <jwakely at redhat dot com>
- To: Hans-Peter Nilsson <hp at bitrange 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 16:06:17 +0100
- 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>
On 07/04/15 10:51 -0400, Hans-Peter Nilsson wrote:
I was more thinking of something like:
#include <atomic>
#include <iostream>
using std::cout;
using std::endl;
struct SoSo {
double d;
int x alignas(sizeof(int));
};
SoSo s __attribute__((__aligned__(16)));
int main(void)
{
cout << "alignof(s): " << alignof(s) << endl;
cout << "alignof(s.d): " << alignof(s.d) << endl;
cout << "alignof(s.x): " << alignof(s.x) << endl;
}
in which I fear s.x would get an alignof the same as the s.d or
s, now or after a while, i.e. higher than specified.
(I get for cris-elf at revision 221891:
alignof(s): 16
alignof(s.d): 1
alignof(s.x): 4
which is kind-of-expected except I thought s.d would get the s
alignment so that just leaves it open whether that could
possibly change.)
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.