@@ -9000,6 +9000,7 @@ finish_template_variable (tree var, tsubst_flags_t complain)
tree tmpl_args = DECL_TI_ARGS (DECL_TEMPLATE_RESULT (templ));
arglist = add_outermost_template_args (tmpl_args, arglist);
+ templ = most_general_template (templ);
tree parms = DECL_TEMPLATE_PARMS (templ);
arglist = coerce_innermost_template_parms (parms, arglist, templ, complain,
/*req_all*/true,
new file mode 100644
@@ -0,0 +1,13 @@
+// PR c++/78906
+// { dg-do compile { target c++14 } }
+
+template <typename> struct A { static constexpr int digits = 0; };
+template <typename> struct B {
+ template <int, typename MaskInt = int, int = A<MaskInt>::digits>
+ static constexpr int XBitMask = 0;
+};
+struct C {
+ using ReferenceHost = B<int>;
+ template <int> static decltype(ReferenceHost::XBitMask<0>) XBitMask;
+};
+int main() { C::XBitMask<0>; }