<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58674>58674</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Decltype of external struct’s member, used in templated class, fails to resolve
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mikmorg
      </td>
    </tr>
</table>

<pre>
    Initial discussion here: https://discourse.llvm.org/t/decltype-of-external-structs-member-used-in-templated-class-fails-to-resolve/66216/1

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.

https://gcc.godbolt.org/z/xPrvEax48

```
struct Foo {
    float value_;
};

float bar;

template <typename T>
struct Animal{};

template <typename T=void>
class Cat : public Animal<T> {
public:
    using value_type_ok = decltype(::Foo::value_);

    void meow() {
        using value_type_fails = decltype(::Foo::value_);

        using value_type_also_ok = decltype(::bar);
    }
};

int main() {
    Cat<>{}.meow();
}
```

@AaronBallman states -

> [[dcl.type.decltype]p1](http://eel.is/c++draft/dcl.type.decltype#1.3) 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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVcuSqzYQ_Rq8UUHZ4OGxYOGxZ1KzSFWq7q1keUtIjVFGSA4S9jhfn26BH_PaxIVBSKhP9-nuo8bKc_1ilFdcM6mcGJ1T1rAOBoiyDeu8PzgcROkzXvSBHQcHidbHPrHDHic9LYDQ_nyA2LYxvHkYDNex88MovIt76BsY4tGBjJWJPfQHzT2-CM2di1uutIu9jQdwVh8BzeV5usrxuYqWu2i5me5_dWDYC0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