https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/101794
This doesn't fix the attached test case, but at least we're not crashing anymore. >From 4fb09d3f10635de87742265ea2e1da12b1ad3679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Sat, 3 Aug 2024 06:43:10 +0200 Subject: [PATCH] [clang][Interp] Convert bocks to DeadBlocks when destroying frames --- clang/lib/AST/Interp/InterpFrame.cpp | 4 +--- clang/test/AST/Interp/new-delete.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/Interp/InterpFrame.cpp b/clang/lib/AST/Interp/InterpFrame.cpp index 1c37450ae1c6e..9e7bf9972a578 100644 --- a/clang/lib/AST/Interp/InterpFrame.cpp +++ b/clang/lib/AST/Interp/InterpFrame.cpp @@ -75,9 +75,7 @@ InterpFrame::~InterpFrame() { if (Func) { for (auto &Scope : Func->scopes()) { for (auto &Local : Scope.locals()) { - Block *B = localBlock(Local.Offset); - if (B->isInitialized()) - B->invokeDtor(); + S.deallocate(localBlock(Local.Offset)); } } } diff --git a/clang/test/AST/Interp/new-delete.cpp b/clang/test/AST/Interp/new-delete.cpp index ae76950f13731..ddf91005c61d9 100644 --- a/clang/test/AST/Interp/new-delete.cpp +++ b/clang/test/AST/Interp/new-delete.cpp @@ -564,6 +564,27 @@ namespace DeleteThis { // both-note {{in call to 'super_secret_double_delete()'}} } +/// FIXME: This is currently diagnosed, but should work. +/// If the destructor for S is _not_ virtual however, it should fail. +namespace CastedDelete { + struct S { + constexpr S(int *p) : p(p) {} + constexpr virtual ~S() { *p = 1; } + int *p; + }; + struct T: S { + // implicit destructor defined eagerly because it is constexpr and virtual + using S::S; + }; + + constexpr int vdtor_1() { + int a; + delete (S*)new T(&a); // expected-note {{delete of pointer to subobject}} + return a; + } + static_assert(vdtor_1() == 1); // expected-error {{not an integral constant expression}} \ + // expected-note {{in call to}} +} #else /// Make sure we reject this prior to C++20 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits