Here when trying to unify P=42 A=T::value we ICE due to the latter's
empty type, which same_type_p dislikes.
PR c++/113644
gcc/cp/ChangeLog:
* pt.cc (unify) <case INTEGER_CST>: Handle NULL_TREE type.
gcc/testsuite/ChangeLog:
* g++.dg/template/nontype30.C: New test.
/* Type INTEGER_CST can come from ordinary constant template args. */
case INTEGER_CST:
case REAL_CST:
- if (!same_type_p (TREE_TYPE (parm), TREE_TYPE (arg)))
+ if (TREE_TYPE (arg) == NULL_TREE
+ || !same_type_p (TREE_TYPE (parm), TREE_TYPE (arg)))
return unify_template_argument_mismatch (explain_p, parm, arg);
while (CONVERT_EXPR_P (arg))
arg = TREE_OPERAND (arg, 0);
--- /dev/null
+// PR c++/113644
+
+template<int> struct A { };
+
+template<class T> void f(A<42>);
+template<class T> void f(A<T::value>);
+
+struct B { static const int value = 42; };
+
+int main() {
+ A<42> a;
+ f<B>(a); // { dg-error "ambiguous" }
+}