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

Reply via email to