https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126713

            Bug ID: 126713
           Summary: GCC accepts an invalid definition of a member variable
                    template of a class template specialization
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: attackerj1113 at gmail dot com
  Target Milestone: ---

The following program is accepted by GCC, but rejected by Clang, MSVC, and EDG:

================================
template <class T>
struct A {
  template <class U>
  static const U u;
};

template <class T>
template <class U>
const U A<int>::u<U> = 1;
================================

https://godbolt.org/z/xv34ejszY

Since A<int> is a non-dependent specialization, the outer template parameter
list cannot be template<class T>. In addition, u<U> does not specialize any
template arguments and is not a valid partial specialization.

This code appears somewhat similar to bug 116981. However, I believe the two
cases are distinct: the code in bug 116981 involves an invalid partial
specialization of a nested class template, whereas the code shown here involves
an invalid template parameter list and definition of a member variable
template.

Reply via email to