[clang] [clang-repl] Set up executor implicitly to account for init PTUs (PR #84758)

Stefan Gränitz via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 11 06:23:35 PDT 2024


================
@@ -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:

With `-O2` this test fails unexpectedly now. Minimal repro:
```
clang-repl> struct A { int a; A(int a) : a(a) {} virtual ~A() {} };
clang-repl> A *a1 = new A(1);
clang-repl: llvm/include/llvm/ADT/SmallVector.h:308: const_reference llvm::SmallVectorTemplateCommon<llvm::PointerAlignElem>::operator[](size_type) const [T = llvm::PointerAlignElem]: Assertion `idx < size()' failed.
```

The following still works and thus I assume it's related to https://github.com/llvm/llvm-project/commit/c861d32d7c2791bdc058d9d9fbaecc1c2f07b8c7:
```
clang-repl> struct A { int a; A(int a) : a(a) {} virtual ~A() {} }; A *a1 = new A(1);
```

@hahnjo Maybe we now process init code that clashes with your above fix. Do you think that's possible? Any idea how to handle it? If possible, I'd like to submit the patch as-is with the test `XFAIL`ed for later investigation.

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


More information about the cfe-commits mailing list