This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libstdc++/65033] Give alignment info to libatomic


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]