]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.dg/cpp0x/alignof6.C
c++: Correct the handling of alignof(expr) [PR88115]
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp0x / alignof6.C
1 // PR c++/88115
2 // { dg-do compile { target c++11 } }
3 // { dg-additional-options "-Wno-pedantic" }
4
5 // Verify the non-standard extension alignof(expr) behaves like
6 // alignof(type) to yield the ABI alignment of the type, and that
7 // __alignof__(expr) behaves like __alignof__(type) to yield the
8 // preferred alignment of the type.
9
10 static_assert(alignof(double{}) == alignof(double), "");
11 static_assert(__alignof__(double{}) == __alignof__(double), "");
12
13 template <class T>
14 void f() {
15 static_assert(alignof(T{}) == alignof(T), "");
16 static_assert(__alignof__(T{}) == __alignof__(T), "");
17 }
18
19 template void f<double>();