[Bug c++/126713] New: GCC accepts an invalid definition of a member variable template of a class template specialization

attackerj1113 at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.