[clang] [clang][bytecode] Check pointer lifetime in CheckDestructor (PR #179957)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 16:48:44 PST 2026


================
@@ -602,6 +602,15 @@ namespace Destructors {
   }
   static_assert(testS() == 1); // both-error {{not an integral constant expression}} \
                                // both-note {{in call to 'testS()'}}
+
+  struct A { int n; };
+  constexpr void double_destroy() {
+    A a;
+    a.~A();
+    a.~A(); // both-note {{destruction of object outside its lifetime}}
----------------
shafik wrote:

If we removed this line, will we also obtain a diagnostic on scope exit since that would also be a double destruction?

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


More information about the cfe-commits mailing list