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

    <tr>
        <th>Summary</th>
        <td>
            Ordinary lookup is executed in the instantiation context
        </td>
    </tr>

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

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

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

<pre>
    Consider the following program.
```c++
template <class T> void f(decltype(bar(foo(T{})))*);
template <class T> void f(...);

template <class T>
struct Wrapper {
    T x;
};

Wrapper<void> foo(int);

void bar(Wrapper<void>);

int main() {
 f<int>(nullptr);
}
```
Note, that there is no `foo` in the template definition context of `f`. So, this program should compile and the 2<sup>nd</sup> overload of `f` should be taken in `main`.

However, Clang 17.0.1 seems to execute ordinary lookup of `foo` erroneously in the context of the instantiation `f<int>(nullptr);`. It finds `foo(int)` and begins to instantiate its return type `Wrapper<void>` to check, whether it can be passed to another function call (`bar`). But, this instantiation fails (a field cannot have incomplete type `void`), and the program doesn't compile. [Demo](https://godbolt.org/z/sxhnzxnh9).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE9v67YT_DTry-IJFGXrz0GH2H7G73dpDw3QMyWuLDY0KZCrxHmfvqAcJU6CFgWIBBS5s7MzY6oYzdkRtbDbw-64UTOPPrR73-3nc9x0Xr-2B--i0RSQR8LBW-tfjDvjFPw5qEsG4gjiAUpxWz3IfVrLV6bLZBUTQnHorYoRH6H4ic_eaBxA1pp6y68Tgaw7FUDWg_cg60eo9lAdQTbrekh_i_-ImmXZ_fV_K7qdRQ5zz_hnUNNEAVP35Tsi4iNeP5Cq4xfUtxIoDql7YnGbwDj-TmEheJvzW93328YxXpRxIGuQzR2pAYpDwk9FtZutnTh8Kq-OXzy5bX_zTCAPyKPi5GUgNBGdRyhFYl0KNG4x-V0rTYNxho132HvHdGX0w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