On Tue, Apr 24, 2018 at 9:19 AM, Jakub Jelinek <ja...@redhat.com> wrote: > 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.
Thanks. How is your build tree configured so that this finds the appropriate runtime libraries? > 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. Done, thanks.
commit 006eabc3e6328b219f2eee271439cb90f8890856 Author: Jason Merrill <ja...@redhat.com> Date: Tue Apr 24 11:50:34 2018 -0400 Testsuite fixes for C++11 alignof change. gcc/testsuite: * c-c++-common/attr-aligned-1.c: Use __alignof__ in C++11. * g++.dg/cpp0x/alignas4.C: Expect 4-byte alignment on x86. diff --git a/gcc/testsuite/c-c++-common/attr-aligned-1.c b/gcc/testsuite/c-c++-common/attr-aligned-1.c index 671e86baeb6..26b62393ac0 100644 --- a/gcc/testsuite/c-c++-common/attr-aligned-1.c +++ b/gcc/testsuite/c-c++-common/attr-aligned-1.c @@ -17,8 +17,8 @@ main () } #if defined(__cplusplus) && __cplusplus >= 201103L -static_assert (alignof (S) == 2 * alignof (double), "alignment of S"); -static_assert (alignof (T) == 2 * alignof (double), "alignment of T"); -static_assert (alignof (const S) == 2 * alignof (double), "alignment of const S"); -static_assert (alignof (const T) == 2 * alignof (double), "alignment of const T"); +static_assert (alignof (S) == 2 * __alignof__ (double), "alignment of S"); +static_assert (alignof (T) == 2 * __alignof__ (double), "alignment of T"); +static_assert (alignof (const S) == 2 * __alignof__ (double), "alignment of const S"); +static_assert (alignof (const T) == 2 * __alignof__ (double), "alignment of const T"); #endif diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas4.C b/gcc/testsuite/g++.dg/cpp0x/alignas4.C index baa56eb8ac5..b66fa651bc2 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alignas4.C +++ b/gcc/testsuite/g++.dg/cpp0x/alignas4.C @@ -1,6 +1,7 @@ // PR c++/59012 // { dg-do compile { target c++11 } } -// { dg-final { scan-assembler "align 8" { target { { i?86-*-* x86_64-*-* } && { ! *-*-darwin* } } } } } +// { dg-final { scan-assembler "align 8" { target { { i?86-*-* x86_64-*-* } && { { ! ia32 } && { ! *-*-darwin* } } } } } } +// { dg-final { scan-assembler "align 4" { target ia32 } } } template <class... T> struct A