[temp.arg.nontype] talks about expressions of type nullptr_t, not
specifically the literal "nullptr".

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 8714be12f8ea82cc4efa0391a78e5ce9ccb067ad
Author: Jason Merrill <ja...@redhat.com>
Date:   Wed Jun 7 17:49:31 2017 -0700

    Fix template argument of nullptr_t type.
    
            * pt.c (convert_nontype_argument): Check NULLPTR_TYPE_P rather than
            nullptr_node.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d8f8d46..40be3c1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6480,7 +6480,7 @@ convert_nontype_argument (tree type, tree expr, 
tsubst_flags_t complain)
 
   /* 14.3.2/5: The null pointer{,-to-member} conversion is applied
      to a non-type argument of "nullptr".  */
-  if (expr == nullptr_node && TYPE_PTR_OR_PTRMEM_P (type))
+  if (NULLPTR_TYPE_P (expr_type) && TYPE_PTR_OR_PTRMEM_P (type))
     expr = fold_simple (convert (type, expr));
 
   /* In C++11, integral or enumeration non-type template arguments can be
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr38.C 
b/gcc/testsuite/g++.dg/cpp0x/nullptr38.C
new file mode 100644
index 0000000..82d75ed
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr38.C
@@ -0,0 +1,9 @@
+// { dg-do compile { target c++11 } }
+
+using nullptr_t = decltype(nullptr);
+
+constexpr nullptr_t n = nullptr;
+
+template <void *> struct A { };
+
+A<n> a;

Reply via email to