gcc/testsuite/g++.dg/cpp2a/consteval-prop4.C
raw| 1 | // P2564R3 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | // From clang's cxx2b-consteval-propagate.cpp. This test ICEd when I worked on |
| 4 | // P2564. |
| 5 | |
| 6 | consteval int f (int); |
| 7 | |
| 8 | struct S { |
| 9 | int a = 0; |
| 10 | int b = f (a); |
| 11 | }; |
| 12 | |
| 13 | constexpr bool |
| 14 | g (auto i) |
| 15 | { |
| 16 | S s{i}; |
| 17 | return s.b == 2 *i; |
| 18 | } |
| 19 | |
| 20 | consteval int |
| 21 | f (int i) |
| 22 | { |
| 23 | return 2 * i; |
| 24 | } |
| 25 | |
| 26 | void |
| 27 | test () |
| 28 | { |
| 29 | static_assert(g(42)); |
| 30 | } |