[clang] Fix crash with modules and constexpr destructor (PR #69076)

Jonas Hahnfeld via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 23:48:45 PST 2024


================
@@ -15754,10 +15754,18 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
     LValue LVal;
     LVal.set(VD);
 
-    if (!EvaluateInPlace(Value, Info, LVal, this,
-                         /*AllowNonLiteralTypes=*/true) ||
-        EStatus.HasSideEffects)
-      return false;
+    {
+      // C++23 [intro.execution]/p5
+      // A full-expression is ... an init-declarator ([dcl.decl]) or a
+      // mem-initializer.
+      // So we need to make sure temporary objects are destroyed after having
+      // evaluated the expression (per C++23 [class.temporary]/p4).
----------------
hahnjo wrote:

Done.

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


More information about the cfe-commits mailing list