================ @@ -14,7 +14,7 @@ struct A { int a; A(int a) : a(a) {} virtual ~A(); }; // PartialTranslationUnit. inline A::~A() { printf("~A(%d)\n", a); } -// Create one instance with new and delete it. +// Create one instance with new and delete it. We crash here now: A *a1 = new A(1); ---------------- weliveindetail wrote:
Let me share some more observations. We **execute** the initial PTU and not only parse it. It shouldn't make a difference for the parser right? Still, I wasn't sure, especially since we unusally **only parse** runtime PTUs. So I made some experiments: ``` Init Runtime Dtor-def | New Delete Automatic (1) Execute Execute Out-of-line | fails - fails Inline | fails - once* (2) Execute Parse Out-of-line | fails - fails Inline | once* fails once (3) Parse Any Out-of-line | works works works Inline | works works works ``` Without `-O2` everything works. Automatic = `A a1(1);` `once` = Works exactly once (including shutdown) `once*` = Same, but only if dtor has side-effects e.g. printf call (1) is the behavior with this patch. (3) was the status-quo before this patch. https://github.com/llvm/llvm-project/pull/84758 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits