[clang] [clang][bytecode] Check dtor instance pointers for active-ness (PR #128732)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 25 09:30:30 PST 2025


================
@@ -504,4 +504,39 @@ namespace AnonymousUnion {
   static_assert(return_init_all().a.p == 7); // both-error {{}} \
                                              // both-note {{read of member 'p' of union with no active member}}
 }
+
+namespace InactiveDestroy {
+  struct A {
+    constexpr ~A() {}
+  };
+  union U {
+    A a;
+    constexpr ~U() {
+    }
+  };
+
+  constexpr bool foo() { // both-error {{never produces a constant expression}}
+    U u;
----------------
shafik wrote:

Can we also add a test to verify that if we use `U u{};` instead that the test passes? Same for the test below as well. 

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


More information about the cfe-commits mailing list