@@ -6879,7 +6879,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
}
else if (NULLPTR_TYPE_P (type))
{
- if (expr != nullptr_node)
+ if (!NULLPTR_TYPE_P (TREE_TYPE (expr)))
{
if (complain & tf_error)
error ("%qE is not a valid template argument for type %qT "
new file mode 100644
@@ -0,0 +1,15 @@
+// PR c++/81671
+// { dg-do compile { target c++11 } }
+
+namespace std { typedef decltype(nullptr) nullptr_t; }
+
+template<class R, class CB> struct Bar
+{};
+template<class R> struct Bar<R, std::nullptr_t>
+{
+ template<std::nullptr_t> struct Bind { constexpr static int const cb = 0; };
+};
+int foo()
+{
+ return Bar<int, decltype(nullptr)>::Bind<nullptr>::cb;
+}