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.

Reply via email to