testsuite: update mangling
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / bit-cast6.C
blob4b70da105b646f47584922b1ee26387d087f234e
1 // PR libstd++/93121
2 // { dg-do compile { target c++20 } }
4 namespace std
6 enum class byte : unsigned char {};
7 template <typename To, typename From>
8 constexpr To
9 bit_cast (const From &from)
11   return __builtin_bit_cast (To, from);
15 struct S { unsigned short s[2]; };
16 constexpr std::byte from1[sizeof (S)]{};
17 constexpr auto to1 = std::bit_cast<S>(from1);
18 constexpr unsigned char from2[sizeof (S)]{};
19 constexpr auto to2 = std::bit_cast<S>(from2);
21 constexpr bool
22 cmp (const S &s1, const S &s2)
24   for (int i = 0; i < sizeof (s1.s) / sizeof (s1.s[0]); i++)
25     if (s1.s[i] != s2.s[i])
26       return false;
27   return true;
30 static_assert (cmp (to1, S{}));
31 static_assert (cmp (to2, S{}));