Hi,
in this P2 ICE on invalid we fail to diagnose an ill-formed variable
template partial specialization and the assert at the beginning of
determine_specialization triggers. Indeed, we didn't diagnose the
problem via check_specialization_scope (there are no template <>, thus
begin_specialization isn't involved). Simply adding a specific check to
check_explicit_specialization exactly when we recognize a variable
template partial specialization seems a safe thing to do and passes
testing. Not sure if the test itself is as simple as possible or is
better done somewhere else...
Thanks, Paolo.
//////////////////////
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 258059)
+++ cp/pt.c (working copy)
@@ -2873,7 +2873,12 @@ check_explicit_specialization (tree declarator,
/* Partial specialization of variable template. */
SET_DECL_TEMPLATE_SPECIALIZATION (decl);
specialization = 1;
- goto ok;
+ if (template_count && DECL_CLASS_SCOPE_P (decl)
+ && template_class_depth (DECL_CONTEXT (decl)) > 0)
+ error ("variable template partial specialization %qD does "
+ "not specialize any template arguments", declarator);
+ else
+ goto ok;
}
else if (cxx_dialect < cxx14)
error ("non-type partial specialization %qD "
Index: testsuite/g++.dg/cpp1y/var-templ58.C
===================================================================
--- testsuite/g++.dg/cpp1y/var-templ58.C (nonexistent)
+++ testsuite/g++.dg/cpp1y/var-templ58.C (working copy)
@@ -0,0 +1,13 @@
+// PR c++/71569
+// { dg-do compile { target c++14 } }
+
+template <class T>
+class Foo
+{
+ template <class U>
+ static bool Bar;
+};
+
+template<class T>
+template<class U>
+bool Foo<T>::Bar<U>; // { dg-error "variable template partial" }