http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59328
Bug ID: 59328 Summary: Template cast operator ambiguity in a delete expression Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: maxime.van.noppen at gmail dot com The following code fails to compile with gcc whereas it works on Clang, Visual Studio and ICC. The version of gcc I tested: 4.4.7, 4.5.3, 4.6.4, 4.7.3, 4.8.1, 4.9.0 20130909 Code snippet: template<typename T> struct Ptr { template<typename U> operator U*() const; operator const T*() const; }; void foo() { Ptr<int> ptr; delete ptr; } Errors: error: default type conversion can't deduce template argument for ‘template<class U> Ptr<T>::operator U*() const [with U = U; T = int]’ error: type ‘struct Ptr<int>’ argument given to ‘delete’, expected pointer My understanding is that the compiler shouldn't consider the templated cast operator and that there shouldn't be an ambiguity here. This is what the other compilers mentioned above do. This is somewhat similar to the bug 58119 and I can confirm that the bug was fixed on 4.9.0 20130909 but this code still fails on that version.