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

    <tr>
        <th>Summary</th>
        <td>
            In template instantiations, Clang doesn't warn about unused variable with dependent initializer
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:diagnostics
      </td>
    </tr>

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

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

<pre>
    Consider:

```
struct PropertyDetails {
    explicit PropertyDetails(int x) : x(x) {}
    int x;
};

template <typename T> void foo(T t) {
  PropertyDetails p = t->details();
}


struct T {
    PropertyDetails details();
};
void f(T* t) {
    foo(t);
}
```

Clang doesn't warn, but GCC does (see https://godbolt.org/z/97Mb6Tnff)

One reason not to warn is that strictly speaking, whether p is unused or not depends on the instantiation, and it would be very annoying to warn in some instantiations and not others. On the other hand, not warning means we miss some unused variables. What do people think?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1U8FyozAM_Rq4aJphTUjCgUObbHb2sNM9ZGbPBivBW2Mztkiafv3KJGmTtMuAsZD03pNkaqeO1dLZoBX6JH9MslWSXdZZdr5HM5AfGoLf3vXo6bhCktoESOZPJz_wha-90Y3-FJWIhbYEr4kogVniZnEyOHu--gA4ReVnyOh6348rYdcbScgoSzr2aGWHsEny77B3WsHWOUbeAF2wz8D3onvOXwE9cKJ6V8g5N8zXrbjuwOa25nvs_wNe9iepUWgiHj9phXMV9LWe26Gc1qWRdgfKYbCJmBMcpOfNEuqB4MdyOXqAIQMitER9iJMWa753TtXO0MT5HVtv_JTzX_VsY7fbSH_F8WwRPMrgLFhHQG5kAR2AWknAvdENmSOEHuWLtrvIf2iRWvTcbg4b7BBQgfNjvkIengrAcBzCcw8kLWlJ2o3SpVXA5-jgBqOgRtijP_JH646M_cFuIbjuLj2MyZHERfYwgecTyWhCy97IEAMiSMTrUHLaAaHTIZwgz3L30mtZG2SUP7FO5aBH1xtkRG1fknydqipXZV7KlDQZrH4y2eWU3uqKrF-NCmTteFJ3jHDQ1J77hPxbaKsZyOg39OngTXU3SA4e6knjOjaM2V9eD713f7Hhw7Tm0gZkEeuiyLM8bSulFrjdTqdqVixq2WS1LOdCLoTIS1HMyjI1skYTqqR4SoRoonLmU1rurAukG8YSSbFKdSUyIbIim2Xlt0IUk2I2L-pMSCy5MdNymkwz7PinmERF8aylvhrF1cMusNPoQOHDKUPQO4s4EjO-HKh1vnrrnMIuHcuoxhr-AeAhfKE">