gcc/testsuite/g++.dg/cpp2a/bit-cast9.C
raw| 1 | // PR c++/98469 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | // { dg-options "-Wall" } |
| 4 | |
| 5 | template<typename T, typename F> |
| 6 | constexpr T |
| 7 | bit_cast (const F &f) noexcept |
| 8 | { |
| 9 | return __builtin_bit_cast (T, f); |
| 10 | } |
| 11 | struct S { int s; }; |
| 12 | constexpr int foo (const S &x) { return x.s; } |
| 13 | constexpr int bar () { return foo (bit_cast<S> (0)); } |
| 14 | constexpr int x = bar (); |
| 15 | static_assert (!x); |