gcc/testsuite/g++.dg/cpp0x/overload-conv-5.C
raw| 1 | // PR c++/106675 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | |
| 4 | struct foo { |
| 5 | int n_; |
| 6 | foo(int n) : n_(n) {} |
| 7 | }; |
| 8 | |
| 9 | struct bar { |
| 10 | int n_; |
| 11 | |
| 12 | operator foo() const { |
| 13 | return foo(n_); |
| 14 | } |
| 15 | operator foo &() { return *reinterpret_cast<foo *>(n_); } |
| 16 | operator foo const &() = delete; |
| 17 | |
| 18 | void crashgcc() { |
| 19 | foo tmp(*this); // { dg-error "ambiguous" } |
| 20 | } |
| 21 | }; |