http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50157
Bug #: 50157 Summary: [C++0x] Non-silent SFINAE in new expression with explicit conversion Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: daniel.krueg...@googlemail.com CC: ja...@redhat.com Build: 4.7.0 20110813 (experimental) gcc 4.7.0 20110813 (experimental) in C++0x mode rejects the following code: --- template<class T> T val(); template<class T, class Arg, class = decltype(::new T(val<Arg>())) > auto test(int) -> char; template<class, class> auto test(...) -> char (&)[2]; struct P { explicit operator bool(); // (#13) }; typedef decltype(test<bool, P>(0)) type; // OK typedef decltype(test<float, P>(0)) type2; // Error (#17) --- "17|error: invalid user-defined conversion from 'P' to 'float' [-fpermissive]| 13|note: candidate is: P::operator bool() <near match>| 13|note: return type 'bool' of explicit conversion function cannot be converted to 'float' with a qualification conversion| 17|error: invalid user-defined conversion from 'P' to 'float' [-fpermissive]| 13|note: candidate is: P::operator bool() <near match>| 13|note: return type 'bool' of explicit conversion function cannot be converted to 'float' with a qualification conversion| ||=== Build finished: 6 errors, 0 warnings ===|" It is correct, that the P->float conversion would be ill-formed, but this needs to be handled silently and the program should be accepted. The compiler seems to have a special problem here with the combination of an explicit conversion function in P and the otherwise feasible bool->float conversion in implicit contexts.