Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang] ICE on void{} #116440

Open
MagentaTreehouse opened this issue Nov 15, 2024 · 3 comments
Open

[Clang] ICE on void{} #116440

MagentaTreehouse opened this issue Nov 15, 2024 · 3 comments
Labels
clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@MagentaTreehouse
Copy link
Contributor

MagentaTreehouse commented Nov 15, 2024

Reproducer:

int main() { void{}; }

This expression void{} causes an ICE in clang trunk. In clang 19.1, it gets rejected.
See compiler Explorer: https://godbolt.org/z/e85YYTaTx

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 15, 2024
@MagentaTreehouse
Copy link
Contributor Author

Assertion:

clang++: /root/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:2077: llvm::Value* {anonymous}::ScalarExprEmitter::VisitInitListExpr(clang::InitListExpr*): Assertion `Ignore == false && "init list ignored"' failed.

Stacktrace:

Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.	<eof> parser at end of file
2.	<source>:1:5: LLVM IR generation of declaration 'main'
3.	<source>:1:5: Generating code for declaration 'main'
 #0 0x0000000003c25588 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c25588)
 #1 0x0000000003c2328c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c2328c)
 #2 0x0000000003b70978 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007b58a8642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007b58a86969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007b58a8642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007b58a86287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007b58a862871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007b58a8639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000000000447734a (anonymous namespace)::ScalarExprEmitter::VisitInitListExpr(clang::InitListExpr*) CGExprScalar.cpp:0:0
#10 0x0000000004472006 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#11 0x00000000044775ec clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44775ec)
#12 0x000000000440086e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x440086e)
#13 0x00000000044246f5 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44246f5)
#14 0x000000000447b84f (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#15 0x0000000004471943 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#16 0x00000000044775ec clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44775ec)
#17 0x000000000440086e clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x440086e)
#18 0x00000000044246f5 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44246f5)
#19 0x0000000003f8b5e5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f8b5e5)
#20 0x0000000003f93324 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f93324)
#21 0x0000000003ffc694 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ffc694)
#22 0x000000000400e538 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x400e538)
#23 0x000000000407743a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x407743a)
#24 0x0000000004072685 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4072685)
#25 0x0000000004072a6b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4072a6b)
#26 0x000000000407cc53 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#27 0x00000000045a58d6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#28 0x0000000004596608 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4596608)
#29 0x0000000006769324 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6769324)
#30 0x00000000045a3488 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45a3488)
#31 0x000000000485dc89 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x485dc89)
#32 0x00000000047ddc6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47ddc6e)
#33 0x0000000004948a3e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4948a3e)
#34 0x0000000000ce3657 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce3657)
#35 0x0000000000cdb21a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x00000000045e6689 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#37 0x0000000003b70e24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b70e24)
#38 0x00000000045e6c7f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#39 0x00000000045acf6d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45acf6d)
#40 0x00000000045ae05d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45ae05d)
#41 0x00000000045b5415 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45b5415)
#42 0x0000000000ce04c3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce04c3)
#43 0x0000000000bb7164 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbb7164)
#44 0x00007b58a8629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#45 0x00007b58a8629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#46 0x0000000000cdacce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdacce)

@EugeneZelenko EugeneZelenko added clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels Nov 15, 2024
@llvmbot
Copy link

llvmbot commented Nov 15, 2024

@llvm/issue-subscribers-clang-codegen

Author: None (MagentaTreehouse)

This expression `void{}` causes an ICE in clang trunk. In clang 19.1, it gets rejected. See compiler Explorer: https://godbolt.org/z/e85YYTaTx

@DimitryAndric
Copy link
Collaborator

Looks like this regressed with llvmorg-20-init-3126-g9d739e5 ("[Clang] Implement CWG2351 void{} (#78060)") by @MitalAshok.

cc @Endilll @shafik @AaronBallman @cor3ntin @zygoloid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

4 participants