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] |
On 05/22/2015 09:13 AM, Jakub Jelinek wrote:
On Fri, May 22, 2015 at 03:59:47PM +0100, Jonathan Wakely wrote:+ alignas(alignof(_Tp2)) unsigned char _M_storage[sizeof(_Tp)];Is alignof(_Tp2) always the same as alignof(_Tp2::_M_t) on all targets (I mean, won't some target align the structure more than its only field)?Hmm, maybe. I don't know.Wouldn't it be safer to use alignof(_Tp2::_M_t) here?Yes.Though, apparently that is a GNU extension, so you'd need to use __alignof__ instead.Yes, that's what I did in an earlier version of the patch, so I'll go back to that.Just grepped around, and e.g. on powerpc64le-linux -std=c++11 -malign-power -O2 typedef double _Tp; struct _Tp2 { _Tp _M_t; }; extern _Tp2 tp2e; int a = alignof(_Tp2); int b = __alignof__(_Tp2::_M_t); int c = alignof(_Tp); int d = __alignof__(tp2e._M_t); int e = alignof(_Tp2::_M_t); we have a = 8, b = 4, c = 8, d = 4, e = 4.
Sorry to divert the discussion from the main topic but the output above doesn't seem quite correct for this target. The alignment of double is required to be 8 by the POWER ABIs so the values of B, D, and E don't match the requirements or the documentation of -malign-power(*). IBM xlC with the default -qalign=power setting prints all 8 on POWER running AIX, as it does with -qalign=natural, and I couldn't get it to match the GCC result with any combination of alignment options. Martin [*] The manual says GCC follows the ABI rules by default, and that the -malign-power option instructs GCC to follow the ABI- specified alignment rules.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |