1 // RUN: %clang_cc1 -std=c++11 -verify %s 2 3 // expected-no-diagnostics 4 using size_t = decltype(sizeof(0)); 5 6 template<typename T, typename U> 7 constexpr T max(T t, U u) { return t > u ? t : u; } 8 9 template<typename T, typename ...Ts> 10 constexpr auto max(T t, Ts ...ts) -> decltype(max(t, max(ts...))) { 11 return max(t, max(ts...)); 12 } 13 14 template<typename...T> struct my_union { 15 alignas(T...) char buffer[max(sizeof(T)...)]; 16 }; 17 18 struct alignas(8) A { char c; }; 19 struct alignas(4) B { short s; }; 20 struct C { char a[16]; }; 21 22 static_assert(sizeof(my_union<A, B, C>) == 16, ""); 23 static_assert(alignof(my_union<A, B, C>) == 8, ""); 24