gcc/testsuite/g++.dg/cpp1y/constexpr-empty2.C
raw| 1 | // { dg-do compile { target c++14 } } |
| 2 | // { dg-additional-options -fno-elide-constructors } |
| 3 | |
| 4 | struct A |
| 5 | { |
| 6 | constexpr A(int) { } |
| 7 | }; |
| 8 | |
| 9 | struct B: A { |
| 10 | constexpr B(int i): A(i) { } |
| 11 | constexpr B(const B& b): A(b) { } |
| 12 | }; |
| 13 | |
| 14 | struct C { |
| 15 | B b; |
| 16 | constexpr C(int i): b(i) { } |
| 17 | constexpr C(const C&c): b(c.b) {} |
| 18 | }; |
| 19 | |
| 20 | constexpr int f() |
| 21 | { |
| 22 | C b1{42}; |
| 23 | C b2{b1}; |
| 24 | b2.b; |
| 25 | return 42; |
| 26 | } |
| 27 | |
| 28 | constexpr int i = f(); |