commit 06d4f1b83e5c393fd22421bbd12135338b891f8e
Author: Jason Merrill <jason@redhat.com>
Date: Sun Feb 5 22:36:59 2012 -1000
PR c++/52088
* cvt.c (build_expr_type_conversion): Check for template conversion.
@@ -1539,6 +1539,17 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
if (DECL_NONCONVERTING_P (cand))
continue;
+ if (TREE_CODE (cand) == TEMPLATE_DECL)
+ {
+ if (complain)
+ {
+ error ("ambiguous default type conversion from %qT",
+ basetype);
+ error (" candidate conversions include %qD", cand);
+ }
+ return error_mark_node;
+ }
+
candidate = non_reference (TREE_TYPE (TREE_TYPE (cand)));
switch (TREE_CODE (candidate))
new file mode 100644
@@ -0,0 +1,13 @@
+// PR c++/52088
+
+struct S
+{
+ template <typename T>
+ operator T *() { return 0; }
+};
+
+int main()
+{
+ S s;
+ delete s; // { dg-error "ambiguous|template|pointer" }
+}