Lookup for a dependent nested type as a base-specifier should be type-only
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Test code ([CE](https://godbolt.org/z/7f8PE88xs)):
```cpp
struct A {
int B;
struct B {};
};
struct S1 : A::B {}; // OK
// - EDG/MSVC: OK
// - GCC (<= 12.5): OK
// - GCC (>= 13.1): error: 'typename A::B' names 'int A::B', which is
// not a type
// - Clang: error: typename specifier refers to non-type member 'B' in
// 'A'
template struct S2 : T::B {};
template class S2;
```
According to [[class.derived.general]/2](https://timsong-cpp.github.io/cppwp/n4950/class.derived.general#2) (from N4950, the C++23 final draft):
> [...] The lookup for the component name of the *type-name* or *simple-template-id* is type-only ([basic.lookup]). [...]
Therefore, the lookup for `B` in `T::B` should be type-only (ignoring non-type names), since `T::B` appears within a *[class-or-decltype](https://timsong-cpp.github.io/cppwp/n4950/class.derived.general#nt:class-or-decltype)* (which can be produced by a *[base-specifier](https://timsong-cpp.github.io/cppwp/n4950/class.derived.general#nt:base-specifier)* or a *[mem-initializer-id](https://timsong-cpp.github.io/cppwp/n4950/class.base.init#nt:mem-initializer-id)*).
Related: [Bug 122192](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122192).
Contributor guide
Research direction
Start by reproducing the linked Compiler Explorer case and trace Clang's lookup handling for dependent names in a base-specifier or class-or-decltype. The fix is complete when the S2 instantiation accepts the nested type B while ignoring A::B's non-type member, with regression coverage for the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100