gcc/testsuite/g++.dg/cpp2a/paren-init10.C
raw| 1 | // PR c++/91363 - P0960R3: Parenthesized initialization of aggregates. |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | // Test from [dcl.init]. |
| 5 | |
| 6 | struct A { |
| 7 | int a; |
| 8 | int&& r; |
| 9 | }; |
| 10 | |
| 11 | int f(); |
| 12 | int n = 10; |
| 13 | |
| 14 | A a1{1, f()}; // OK, lifetime is extended |
| 15 | A a2(1, f()); // well-formed, but dangling reference |
| 16 | A a3{1.0, 1}; // { dg-error "narrowing conversion" } |
| 17 | A a4(1.0, 1); // well-formed, but dangling reference |
| 18 | A a5(1.0, static_cast<int&&>(n)); // OK |