<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63804>63804</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang incorrectly tries to call the destructor of anonymous unions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
rejects-valid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cor3ntin
</td>
</tr>
</table>
<pre>
Clang rejects this valid C++ code
struct S{
~S() {}
};
struct A {
union {
S arr_;
};
~A(); // user-provided!
};
auto foo() {
return A{S()};
}
https://godbolt.org/z/oqWYGnzf9
Clang complains that the destructor of the union is implicitly deleted, but destructors of anonymous unions should not be called (per http://eel.is/c++draft/class.dtor#13) or exist.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0k82OmzAQx59muIw2gnE-4MAhJKIPsIeqp8rYk-DKsVPbrLp72GevDFGaXW05GPEX__n4zVjGaM6OuYVNB5tjIac0-tAqH4RLxhWD16_twUp3xsC_WKWIaTQRX6Q1Gg9AHVCHymuG8gjlfjljCpNK-Ay7bhEQEd-fgWqgBrO6O97-3x1BdF949_jBPDnj3UcpP88oQ_h5j5Clx4j4vl9ygugQqAfqcYocnq7BvxjNGqj6Xx1ySh5P3j8Ufc8ROE3B4R523a2pD_57c_M5pnSNIPZL_rPXg7dp5cMZqH8D6v3v7z--ubdT82hakCt_uVppXIYuE6aRUfMCyAf0p1lZ0JiI5nK1RplkX1Gz5ZTbO-AwpQdTzC7pvHu9-Cku3ohx9JPV6HzCgVFJa1kjUH3lgLn8e_XMdmUiUK-WyesgTyl_WhnjSicfgEQlMjAfkP-YmFaFboVuRCMLbqtt3ZR1Va3rYmwHpUupZENyIwbWTd3IdVPzRmtBm3qrC9NSSaLcVVUlKqJ6pXmna6oaNahGbcUG1iVfpLEra18uGWlhYpy43Yq6XBdWDmzjvNlEKgMFsT8F7xI7DURAByC6rfXTvNFZ3RyL0OaAT8N0jrAurYkp_kuRTLJ8uxPGKR8Cq8w8BcMRk5_5fTGrz9SLKdj203KYNE7DSvkLUJ8T3l55X3OVQP3cYJ7A3OPfAAAA__9cRSNr">