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

    <tr>
        <th>Summary</th>
        <td>
            Error: the type of variable template specialization declared with deduced type depends on itself
        </td>
    </tr>

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

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

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

<pre>
    https://godbolt.org/z/eWjrxjeds
GCC and MSVC accept this

```cpp
template<int>
struct A {
        template<int x>
        static constexpr auto foo = []<int y> {
                return A<(x + y)>();
        };

        template<int x>
        using bar = decltype(foo<0>.template operator()<x>());

        template<int x>
        using baz = decltype(foo<0>.template operator()<x>());
};

A<0> x;

int main() {}
```

```
<source>:9:29: error: member reference base type 'const auto' is not a structure or union
    9 |         using bar = decltype(foo<0>.template operator()<x>());
      | ~~~~~~^         ~~~~~~~~
<source>:8:2: note: in instantiation of template type alias 'bar' requested here
    8 |         template<int x>
      | ^
<source>:15:6: note: in instantiation of template class 'A<0>' requested here
   15 | A<0> x;
      |      ^
<source>:12:23: error: the type of variable template specialization 'foo<0>' declared with deduced type 'const auto' depends on itself
   12 |         using baz = decltype(foo<0>.template operator()<x>());
      | ^
<source>:11:2: note: in instantiation of template type alias 'baz' requested here
   11 |         template<int x>
      | ^
<source>:15:6: note: in instantiation of template class 'A<0>' requested here
   15 | A<0> x;
      |      ^
2 errors generated.
Compiler returned: 1
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcVU2TozYQ_TXtS9e6oDEGDhwYxs4pp1QlZyEaWxMsEUnMenzY354S4PXO12YqmVMoqqwyUr_3-j1Jwjl10MwlpHeQ3q_E6I_Gljt5afjPVWPap_Lo_eAgqYD2QPuDaRvT-7WxB6D9BWjPfzzY8wO3DqLql7pGoVv89bffaxRS8uDRH1X4FN5tNL9yGCCqPJ-GXniGpFbaQ7KDqHLejtJjhZDdTYuK57PwPM-DqHBeeCVRGu08nweLYvQGO2MQknuc9SyLniDZ3SpCVFj2o9VYQVID5WcEusMnoCIUp3waXCdn99fxT9mMTukDNsJO6C3L3j8NDJR3xkBSR5Ds1tfFaAa2wht7xarPN-Ab9ofwLp-G94PQaqkQ8Ja_AvpJKD2vmpqZ3f_o6QuLwzipnRmt5ACWVAUkVQCrkK01NgxOfGrYouWOLWvJ2AjHGIQgUDY5O7kKlKFyqI1HgXNERstoLI5aGQ1RhYgYWNV4fT7dkLlsgPg2PZDuvoN9W57XqvOgOmjVJrhYodKotPNCeyW8MhpNh995TNJFr4QLDWiEDcot_zWy89zikS0vTPJnYt-OyY0xpLvX1OIUkmr7YW6yF26idU3He9zidMJ8GaIbm3nwJqXQKkqehcQfl76YDh-FVaLp-cbKDSyV6NVlJgyU3fwNBIPxwnKLX5U_YsvtKLl9J2ItD6xbh0aj8o77btFDbwbr03beP9kU_6cIXd61Kf5_RIjmqDg8sA7N5nYNUVWb06D66XAJRz23gVz84oRatWXSFkkhVlzGWUrxdpPE0epYdrKJN7KLsizrMqKCukwmVORN18bbdNusVEkRpVEWR_E2zilfU5rLJtuIPGUScZfDJuKTUP267x9P4bZcKedGLuNNVhS06kXDvZtuXSLNX3H6CkThErZlWPSlGQ8ONlGvnHe3Ml75nsvdv9odP9kMr7K_Gm3_8u5X_jg2a2lOQPtAaPn5MljzwNID7ScZDmi_6Hws6e8AAAD__2KGe5I">