| 1 |
// PR c++/92812 |
| 2 |
// P1975R0 |
| 3 |
// { dg-do compile { target c++20 } } |
| 4 |
|
| 5 |
struct A { int i; }; |
| 6 |
struct A2 { int i; A2(int); }; |
| 7 |
struct A3 { int i; explicit A3(int); }; |
| 8 |
|
| 9 |
struct X { A a; }; |
| 10 |
auto x = static_cast<X>(42); // { dg-error "could not convert" } |
| 11 |
|
| 12 |
struct X2 { A2 a; }; |
| 13 |
auto x2 = static_cast<X2>(42); |
| 14 |
|
| 15 |
struct X3 { A3 a; }; |
| 16 |
// Aggregate-initialization copy-initializes, so the explicit ctor |
| 17 |
// isn't considered. |
| 18 |
auto x3 = static_cast<X3>(42); // { dg-error "could not convert" } |
| 19 |
|
| 20 |
struct NonAggr { int i; virtual void foo (); }; |
| 21 |
auto x4 = static_cast<NonAggr>(42); // { dg-error "no matching" } |