@@ -5454,7 +5454,7 @@ unify_overload_resolution_failure (bool explain_p, tree arg)
static tree
convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
{
- tree expr_type;
+ tree expr_type, initial_expr = expr;
/* Detect immediately string literals as invalid non-type argument.
This special-case is not needed for correctness (we would easily
@@ -5658,10 +5658,10 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
}
else
{
- tree decl;
+ tree decl = STRIP_NOPS (initial_expr);
- decl = ((TREE_CODE (expr) == ADDR_EXPR)
- ? TREE_OPERAND (expr, 0) : expr);
+ decl = ((TREE_CODE (initial_expr) == ADDR_EXPR)
+ ? TREE_OPERAND (initial_expr, 0) : initial_expr);
if (TREE_CODE (decl) != VAR_DECL)
{
error ("%qE is not a valid template argument of type %qT "
new file mode 100644
@@ -0,0 +1,15 @@
+// Origin PR c++/55311
+// { dg-do compile { target c++11 } }
+
+template <const char *const C, typename T>
+struct A
+{};
+
+struct B {};
+
+extern constexpr char HELLO_WORLD[] = "hello world";
+
+A<HELLO_WORLD, B> g; // <-- This works fine
+
+template <typename T>
+using PartiallySpecialized = A<HELLO_WORLD, T>; // <-- This fails