1 // P0466R5
2 // { dg-do compile { target c++20 } }
3 
4 namespace std
5 {
6 template <class S1, class S2, class M1, class M2>
7 constexpr bool
is_corresponding_member(M1 S1::* m1,M2 S2::* m2)8 is_corresponding_member (M1 S1::*m1, M2 S2::*m2) noexcept
9 {
10   return __builtin_is_corresponding_member (m1, m2);
11 }
12 // { dg-message "'__builtin_is_corresponding_member' not well defined for anonymous unions" "" { target *-*-* } .-2 }
13 }
14 
15 struct S {};
16 struct T {};
17 struct I { int a; };
18 struct alignas(16) J { const int b; };
19 struct K { char b; char s[15]; alignas(16) I c; short d; };
20 struct L { char d; char t[15]; J e; short f; };
21 struct U { int a0; [[no_unique_address]] S a1; [[no_unique_address]] S a2; [[no_unique_address]] S a3; short a4; };
22 struct V { int b0; [[no_unique_address]] S b1; [[no_unique_address]] T b2; [[no_unique_address]] S b3; short b4; };
23 struct U1 { int a0; [[no_unique_address]] S a1; [[no_unique_address]] S a2; [[no_unique_address]] S a3; short a4; };
24 struct V1 { int b0; [[no_unique_address]] S b1; [[no_unique_address]] T b2; [[no_unique_address]] S b3; short b4; };
25 struct A { int a; union { short b; long c; }; int d; signed char e; int f; };
26 struct B { const int a; union { signed long b; short c; }; volatile int d; unsigned char e; int f; };
27 
28 static_assert (!std::is_corresponding_member (&K::d, &L::f));
29 static_assert (std::is_corresponding_member (&U::a1, &V::b1));
30 static_assert (!std::is_corresponding_member (&U::a2, &V::b2));
31 static_assert (!std::is_corresponding_member (&U::a3, &V::b3));
32 static_assert (!std::is_corresponding_member (&U1::a3, &V1::b3));
33 static_assert (!std::is_corresponding_member (&A::b, &B::c));
34 constexpr auto a = std::is_corresponding_member (&A::c, &B::b);		// { dg-message "required from here" }
35