[clang] [Sema] Instantiate destructors for initialized anonymous union fields (PR #128866)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 28 13:07:21 PST 2025


================
@@ -51,18 +51,18 @@ namespace disabled_dtor {
   union disable_dtor {
     T val;
     template<typename...U>
-    disable_dtor(U &&...u) : val(forward<U>(u)...) {}
+    disable_dtor(U &&...u) : val(forward<U>(u)...) {} // expected-error {{attempt to use a deleted function}}
----------------
efriedma-quic wrote:

I think this error is correct: if the body of the constructor throws, we call the destructor for val.

https://github.com/llvm/llvm-project/pull/128866


More information about the cfe-commits mailing list