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

    <tr>
        <th>Summary</th>
        <td>
            C++: Clang allows a wrongly-named destructor in Templates.
        </td>
    </tr>

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

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

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

<pre>
    
The following code compiles fine on clang (14.0 and latest trunk), even though the destructor of `Foobar` is not called `~Foobar` but `~Node`. GCC reports an error as expected.

```
struct Node {}; 
template <int x> 
struct Foobar { ~Node() {} }; 
Foobar<5> f{};
```

https://godbolt.org/z/T8jTrPYW1
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtUk1v2zAM_TXyhahhy585-JA4zYAdhh0CDDvKFm2rUyRDkpt2v360k67tMICmSFN8fCTVWfnasOTIkv15Qhis1vaqzAi9lUjqMiuNHgZlEKyBXguKMV6neZyAMBK0COgDBLeYX4zvGG8Bn9FAmOwyTnQgSLrglj5YB3YAViYnazvhyADlwdgAvdAa5Rpi1eN7tFvC_d83YkNWDF_aFhzO1gVP5QGdI1ThAV9m7APK-NbLXVPuTTb3xgJWLGDVgVVHlh3gFgt4mddWgGWtMgFeWPYIn9JutNZEeCPEa-r4DgWf4O49ZG2x4gx_q_2X101PIcyeZXvGTySjlZ3VIbZuJO83fef66ey-__yRRtikZVHvdiVP6kg2mdxlOxEFFTQ2LeOHVbI9tNuuxLpQmhVcnTWjfn0w4kKj_rATZeB8797H0eJ08w8VFaali-ktkKP189vxMDv7REMnV3m_oCejKKuKR1OTYT30RdoNWFeYdDKXPME-KWTai7Kv80iLDrVvWEFsucErbBBks-IYqYYnnCcVr5M6LfMi7lLOS8yrspYi7_Oc5QlehNLxymOdUeSajVK3jJ6CWvng34PCezUaxK0c4YuFXqdrvp6UUT7aKjcb8z9nye3H">