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

    <tr>
        <th>Summary</th>
        <td>
            Member lookup fails with templated class and --target=x86_64-pc-windows
        </td>
    </tr>

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

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

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

<pre>
    The following code compiles on MSVC, gcc, and clang-without-args, but fails on `clang --target=x86_64-pc-windows`:
```
template <typename T> // Making S1 non-templated fixes the bug.
struct S1 {
  void F1();
  auto F2() {
    struct S2 {  // Moving this struct out above F2() fixes the bug.
 S2() { ps1->F1(); }
      S1* ps1 = nullptr;
    };
    return S2();
  }
};
decltype(S1<void>().F2()) s2;
```

Godbolt repro: https://godbolt.org/z/E1aE7fc3d

There's some kind of problem looking up `ps1` while instantiating `S2`. I assume setting the target to "Windows" changes template instantiation in a way meant to be MSVC-compatible (but which clearly isn't).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE-PqzYQ_zTDZURk7ATIgcO-Tah62FNW7bEyZgLuGhths3nbT18ZNgl6qipFMZ6Z38zP8096rztLVMHhBxxOiZxD76Zq_JA-aNsljWu_qvee8OqMcTdtO1SuJVRuGLUhj87i2-WPV-Cv2CkVD2lbVEbaLr3p0Ls5pHLqfNQ0c8Cr1GZBQc4WK0zTIKeOAojTzzL_K9-no0pv2rbu5iFnIF6AnYC9xO_1t1wDDaORgRDEa_gaycqB8B3EGYHXwGt8kx-R7iVD62x6N2_xqn-Sx9ATNnO3W535MM0qRFsofqwixE-nW6wz4CXwI4iHXM7BYc1X-RaAePfDoxgfTNxnZBJ67e8Wbg4oG_dJT0f_xQsvmzA4-iwFcd5QQihOz-iIlwz4S7RDECe0szFjmDbUcQFs7xOFebKPOBvdw_UW0pIyMdvAy0sG4jXmCMR5Be_ub4mEPX-Afqnc-v-baxtnAk40Tg7EC_YhjD5We0lat6p3buqA1_8Ar8-ZPBdXJdqtl_eeJgJeePRuIPzQtkV3xXFyjaEBjXNLE8xj7LfRZ5AzvPXaEGrrg7RBy9jnUXvhkLMd_o7S-3kg9BTCWjbCtUMxOATO__zuTc5R9dJ2sWr3Ztx4dRa1RYk3-YUDSbvAG1rGJY3zI4NuDCHwMg7GrdeqR2VITuYLtbfAixCTmrSVaI_iKBOqsrw8CiYY2yd9lWc5y8qiLI55kx3KhjIqr0xJ4i1XqjgkuuKMC1Zke8YPjO13JArFy_zY0oHasjjCntEgtdkZ8znEVCfa-5mqXJSHIjGyIeOXzcC5pRsuSuA8Loqpipi0mTsPe2a0D_7pJehgqHqjoaFpqcE8fg9-XAn4nEVlpPfLxvi_LZDMk6l-aQ8d-rnZKTcAr2Pc7yMdJ_c3qQC8Xth64PXymn8DAAD__3vce7o">