On Mon, Apr 23, 2018 at 04:49:24PM -0400, Jason Merrill wrote: > On Tue, Apr 17, 2018 at 8:50 AM, Joseph Myers <jos...@codesourcery.com> wrote: > > On Tue, 10 Apr 2018, Jason Merrill wrote: > > > >> But really this is beside the point: the x86 ABI says that the > >> alignment of double is 4, so alignof(double) should be 4 regardless of > >> what GCC wants to do internally. And I think the same is true of > >> __alignof__. > > > > __alignof__ needs to stay reflecting the preferred, standalone alignment > > of 8 bytes; changing that is ABI-incompatible; code such as that in > > stddef.h uses __attribute__((__aligned__(__alignof__(long long)))) to give > > structure members the same alignment those types would have for standalone > > objects. (This doesn't affect the alignment of max_align_t *now* on i386, > > but only because that now includes __float128 as well.) > > In that case, here's a patch following the 52023 change to the C front > end, to change only "alignof". > > Tested x86_64-pc-linux-gnu, applying to trunk.
This regressed: +FAIL: c-c++-common/attr-aligned-1.c -std=c++11 (test for excess errors) +UNRESOLVED: c-c++-common/attr-aligned-1.c -std=c++11 compilation failed to produce executable +FAIL: c-c++-common/attr-aligned-1.c -std=c++14 (test for excess errors) +UNRESOLVED: c-c++-common/attr-aligned-1.c -std=c++14 compilation failed to produce executable +FAIL: g++.dg/cpp0x/alignas4.C -std=c++11 scan-assembler align 8 +FAIL: g++.dg/cpp0x/alignas4.C -std=c++14 scan-assembler align 8 on i686-linux, can be reproduced even with just make check-gcc check-g++ RUNTESTFLAGS="--target_board=unix\{-m64,-m32\} dg.exp='attr-aligned-1.c alignas4.C'" on x86_64-linux. On alignas4.C, this was changed with r249409, perhaps we can limit the target to && { ! ia32 } or similar, or do we want to expect align 4 for ia32? attr-aligned-1.c testcase doesn't work if __alignof__ (double) != alignof (double). Either we should use __alignof__ in the static_asserts, or guard the static_asserts for targets known not to have different results between the two. > commit c42f365685b86fa7cecc2666adf93037f7bd0289 > Author: Jason Merrill <ja...@redhat.com> > Date: Tue Apr 10 11:48:51 2018 -0400 > > PR c++/69560 - wrong alignof(double) on x86. > > CWG 1879 - Inadequate definition of alignment requirement. > * cp-tree.h (ALIGNOF_EXPR_STD_P): New. > * typeck.c (cxx_sizeof_or_alignof_type): Add std_alignof parm. > (cxx_sizeof_expr, cxx_sizeof_nowarn, cxx_alignas_expr) > (cxx_alignof_expr): Pass it. > * parser.c (cp_parser_unary_expression): Pass it. > * pt.c (tsubst_copy): Copy it. > (tsubst_copy_and_build): Pass it. > * decl.c (fold_sizeof_expr): Pass it. Jakub