| 1 |
// PR c++/97523 |
| 2 |
// { dg-do compile } |
| 3 |
// We were turning the () into {} which made it seem like |
| 4 |
// aggregate-initialization (we are dealing with arrays here), which |
| 5 |
// performs copy-initialization, which only accepts converting constructors. |
| 6 |
|
| 7 |
struct T { |
| 8 |
explicit T(); |
| 9 |
T(int); |
| 10 |
}; |
| 11 |
|
| 12 |
void |
| 13 |
fn (int n) |
| 14 |
{ |
| 15 |
new T[1](); |
| 16 |
new T[2](); |
| 17 |
new T[3](); |
| 18 |
new T[n](); |
| 19 |
#if __cpp_aggregate_paren_init |
| 20 |
new T[](); |
| 21 |
new T[2](1, 2); |
| 22 |
// T[2] is initialized via copy-initialization, so we can't call |
| 23 |
// explicit T(). |
| 24 |
new T[3](1, 2); // { dg-error "explicit constructor" "" { target c++20 } } |
| 25 |
#endif |
| 26 |
} |