| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
|
| 3 |
template <auto N> struct A {}; |
| 4 |
template <class,class> struct assert_same; |
| 5 |
template <class T> struct assert_same<T,T> {}; |
| 6 |
|
| 7 |
#define TEQ(X,Y) static_assert(__is_same(A<(X)>,A<(Y)>)) |
| 8 |
#define TNEQ(X,Y) static_assert(!__is_same(A<(X)>,A<(Y)>)) |
| 9 |
|
| 10 |
union U { |
| 11 |
int i; int j; |
| 12 |
constexpr U(int i): i(i) {} |
| 13 |
constexpr U(unsigned u): j(u) {} |
| 14 |
}; |
| 15 |
|
| 16 |
TEQ(U(0),U(0)); |
| 17 |
|
| 18 |
// Calling the other constructor initializes a different member with the same |
| 19 |
// value. We need to distinguish these. |
| 20 |
TNEQ(U(0),U(0u)); |
| 21 |
|
| 22 |
// { dg-final { scan-assembler "_Z1f1AIXtl1UEEE" } } |
| 23 |
void f(A<U(0)>) { } |
| 24 |
// { dg-final { scan-assembler "_Z1g1AIXtl1Udi1jLi0EEEE" } } |
| 25 |
void g(A<U(0u)>) { } |