https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/147514
Caused by an incorrect assertion. Fixes #116440 >From 4b536efe500f3b9099d1cf1a1a8775633e193249 Mon Sep 17 00:00:00 2001 From: Corentin Jabot <corentinja...@gmail.com> Date: Tue, 8 Jul 2025 14:34:16 +0200 Subject: [PATCH] [Clang] Fix crash on `void{}` Caused by an incorrect assertion. Fixes #116440 --- clang/lib/CodeGen/CGExprScalar.cpp | 4 +++- clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index fc441dd92d1ee..44931d0481e26 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -2114,8 +2114,10 @@ static int getAsInt32(llvm::ConstantInt *C, llvm::Type *I32Ty) { Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { bool Ignore = TestAndClearIgnoreResultAssign(); (void)Ignore; - assert (Ignore == false && "init list ignored"); unsigned NumInitElements = E->getNumInits(); + assert(Ignore == false || + (NumInitElements == 0 && E->getType()->isVoidType()) && + "init list ignored"); // HLSL initialization lists in the AST are an expansion which can contain // side-effecting expressions wrapped in opaque value expressions. To properly diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp index 2f6a6820a7589..478ad40359727 100644 --- a/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp +++ b/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp @@ -5,3 +5,12 @@ void f() // CHECK: store i32 0 int i{}; } + + +namespace GH116440 { +void f() { + void{}; + void(); +} + +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits