Decltype of external struct's member, used in templated class, fails to resolve

I’m not sure if this is a bug in clang, but it seems like it. For some reason, when I use decltype(Foo::value_) from a method in a templated class, inheriting from a templated base class, decltype fails with “… is not a member of THIS_CLASS”.

Is this a clang bug? I can work around it by typedef’ing the decltype expression outside of a method.

1 Like

Yeah, can’t say I’m sure if it’s a bug or not. Maybe @AaronBallman has better C++ language nuance.

This looks like a bug to me.

[dcl.type.decltype]p1 basically says that we do the lookup of the qualified id and the resulting type is the type of what we find. There’s nothing special about doing the lookup from within a member function. So we should be able to find that member. And we do find that member if Cat is not a template type or (even more oddly) if Cat does not inherit from anything, so something is definitely wonky here.

The code is accepted by GCC, MSVC, and ICC, which also suggests we’re in the wrong.

Would you mind filing this issue at Issues · llvm/llvm-project · GitHub so we don’t lose track of it?

1 Like

Agreed with Aaron… that is either a super subtle fallout from standardeeze that I don’t know, or its a bug. I’m leaning toward the later :slight_smile:
Please file the issue as aaron asked.

1 Like

Excellent, thank you for responding so quickly.

Issue created: Decltype of external struct’s member, used in templated class, fails to resolve · Issue #58674 · llvm/llvm-project · GitHub