https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118347
Bug ID: 118347
Summary: Nested template class name inside template class with
default parameter is not treated as a dependent
template name
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: wangbopku15 at gmail dot com
Target Milestone: ---
Consider the following code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename T, typename NOS=int>
struct holder
{
template<typename F> struct fn {};
struct t2 : holder<T>::fn<T> {}; // fail
};
holder<int> holder_1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
https://godbolt.org/z/qn5eW5M1M
MSVC, ICC, and Clang agree that the 'template' disambiguator before 'fn<T>'
here is necessary to make this work, but GCC seems not.
The reason might be that 'holder<T>::fn<T>' seems to be more like an unknown
specialization and 'fn' cannot be automatically identified as a template name
when the argument list of 'holder' is not completely specified, as the
following code works in every compiler:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename T, typename NOS=int>
struct holder
{
template<typename F> struct fn {};
struct t2 : holder<T, NOS>::fn<T> {}; // fail
};
holder<int> holder_1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
https://godbolt.org/z/4nWjzxG8o
Please see https://timsong-cpp.github.io/cppwp/n4868/temp.names#4([temp.names],
13.3.4), which might be helpful for this.