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 crash #53983

Closed
cho-regin opened this issue Feb 22, 2022 · 7 comments
Closed

clang crash #53983

cho-regin opened this issue Feb 22, 2022 · 7 comments
Assignees
Labels

Comments

@cho-regin
Copy link

cho-regin commented Feb 22, 2022

Crashing in clang-trunk https://godbolt.org/z/EndP9c7qE

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O2 --std=c++2a <source>
1.	<source>:235:1: current parser token 'bool'
2.	<source>:226:3 <Spelling=<source>:200:20>: LLVM IR generation of declaration 'main'
3.	<source>:226:3 <Spelling=<source>:200:20>: Generating code for declaration 'main'
 #0 0x0000557424fbb27f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000557424fb9150 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35b9150)
 #2 0x0000557424ef2ed8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fc70ca033c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x000055742477ee02 llvm::PointerType::get(llvm::Type*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x2d7ee02)
 #5 0x000055742549b577 clang::CodeGen::CGBuilderTy::CreateStructGEP(clang::CodeGen::Address, unsigned int, llvm::Twine const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a9b577)
 #6 0x00005574255caf8d clang::CodeGen::CodeGenFunction::EmitAggregateStore(llvm::Value*, clang::CodeGen::Address, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bcaf8d)
 #7 0x00005574256509f1 (anonymous namespace)::AggExprEmitter::VisitConstantExpr(clang::ConstantExpr*) CGExprAgg.cpp:0:0
 #8 0x000055742564ed57 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) CGExprAgg.cpp:0:0
 #9 0x0000557425650bc1 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c50bc1)
#10 0x0000557425643111 clang::CodeGen::CodeGenFunction::EmitAnyExprToMem(clang::Expr const*, clang::CodeGen::Address, clang::Qualifiers, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c43111)
#11 0x00005574256476e6 clang::CodeGen::CodeGenFunction::EmitMaterializeTemporaryExpr(clang::MaterializeTemporaryExpr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c476e6)
#12 0x000055742563ea5e clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c3ea5e)
#13 0x000055742564731d clang::CodeGen::CodeGenFunction::EmitReferenceBindingToExpr(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c4731d)
#14 0x00005574255d7b74 clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bd7b74)
#15 0x00005574255d92bf clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const> >, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bd92bf)
#16 0x000055742563ccf3 clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType, clang::CodeGen::CGCallee const&, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::Value*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c3ccf3)
#17 0x0000557425648ae8 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c48ae8)
#18 0x0000557425649fcb clang::CodeGen::RValue llvm::function_ref<clang::CodeGen::RValue (clang::CodeGen::ReturnValueSlot)>::callback_fn<(anonymous namespace)::AggExprEmitter::VisitCallExpr(clang::CallExpr const*)::'lambda'(clang::CodeGen::ReturnValueSlot)>(long, clang::CodeGen::ReturnValueSlot) CGExprAgg.cpp:0:0
#19 0x000055742564d49b (anonymous namespace)::AggExprEmitter::withReturnValueSlot(clang::Expr const*, llvm::function_ref<clang::CodeGen::RValue (clang::CodeGen::ReturnValueSlot)>) CGExprAgg.cpp:0:0
#20 0x000055742564d873 (anonymous namespace)::AggExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprAgg.cpp:0:0
#21 0x000055742564dc3b clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) CGExprAgg.cpp:0:0
#22 0x0000557425650bc1 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c50bc1)
#23 0x000055742562f1fe clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c2f1fe)
#24 0x000055742562f8c9 clang::CodeGen::CodeGenFunction::EmitAnyExprToTemp(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c2f8c9)
#25 0x00005574255d7c5b clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bd7c5b)
#26 0x00005574255d92bf clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const> >, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bd92bf)
#27 0x000055742563ccf3 clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType, clang::CodeGen::CGCallee const&, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::Value*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c3ccf3)
#28 0x0000557425648ae8 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c48ae8)
#29 0x0000557425685250 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#30 0x0000557425679bf3 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#31 0x0000557425679bdc (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#32 0x000055742567aa98 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#33 0x000055742567c2a3 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c7c2a3)
#34 0x0000557425635315 clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c35315)
#35 0x00005574253c7fb8 clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*, llvm::BasicBlock*, llvm::BasicBlock*, unsigned long, clang::Stmt::Likelihood) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39c7fb8)
#36 0x00005574253780d1 clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39780d1)
#37 0x0000557425372ad9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3972ad9)
#38 0x000055742537820e clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x397820e)
#39 0x0000557425372ad9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3972ad9)
#40 0x000055742537852c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x397852c)
#41 0x00005574253c8c43 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39c8c43)
#42 0x00005574253d273a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39d273a)
#43 0x0000557425419198 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a19198)
#44 0x00005574254162d5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a162d5)
#45 0x0000557425416a13 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a16a13)
#46 0x000055742541cdb1 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5387) CodeGenModule.cpp:0:0
#47 0x0000557425f70251 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#48 0x0000557425f64ef2 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4564ef2)
#49 0x0000557426de41cc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x53e41cc)
#50 0x0000557425f6e1f2 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x456e1f2)
#51 0x000055742596ac41 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f6ac41)
#52 0x00005574259053e2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f053e2)
#53 0x0000557425a37013 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4037013)
#54 0x0000557422bafca4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11afca4)
#55 0x0000557422babc5d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#56 0x00005574257a19f5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#57 0x0000557424ef34c3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x34f34c3)
#58 0x00005574257a3ac8 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3da3ac8)
#59 0x0000557425776efa clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d76efa)
#60 0x0000557425777a3f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d77a3f)
#61 0x0000557425780405 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3d80405)
#62 0x0000557422abb752 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0x10bb752)
#63 0x00007fc70c4b30b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#64 0x0000557422bab7da _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x11ab7da)
clang-15: error: clang frontend command failed with exit code 139 (use -v to see invocation)
ASM generation compiler returned: 139
<source>:1:9: warning: #pragma once in main file [-Wpragma-once-outside-header]
#pragma once
        ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-trunk-20220222/bin/clang-15 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name example.cpp -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-trunk-20220222/lib/clang/15.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/backward -internal-isystem /opt/compiler-explorer/clang-trunk-20220222/lib/clang/15.0.0/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 --std=c++2a -fdeprecated-macro -fdebug-compilation-dir=/app -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-27c9b0.o -x c++ <source>
1.	<source>:235:1: current parser token 'bool'
2.	<source>:226:3 <Spelling=<source>:200:20>: LLVM IR generation of declaration 'main'
3.	<source>:226:3 <Spelling=<source>:200:20>: Generating code for declaration 'main'
 #0 0x0000560613bbb27f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000560613bb8b3d SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fe03ba043c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #3 0x000056061337ee02 llvm::PointerType::get(llvm::Type*, unsigned int) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x2d7ee02)
 #4 0x000056061409b577 clang::CodeGen::CGBuilderTy::CreateStructGEP(clang::CodeGen::Address, unsigned int, llvm::Twine const&) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3a9b577)
 #5 0x00005606141caf8d clang::CodeGen::CodeGenFunction::EmitAggregateStore(llvm::Value*, clang::CodeGen::Address, bool) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3bcaf8d)
 #6 0x00005606142509f1 (anonymous namespace)::AggExprEmitter::VisitConstantExpr(clang::ConstantExpr*) CGExprAgg.cpp:0:0
 #7 0x000056061424ed57 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) CGExprAgg.cpp:0:0
 #8 0x0000560614250bc1 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c50bc1)
 #9 0x0000560614243111 clang::CodeGen::CodeGenFunction::EmitAnyExprToMem(clang::Expr const*, clang::CodeGen::Address, clang::Qualifiers, bool) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c43111)
#10 0x00005606142476e6 clang::CodeGen::CodeGenFunction::EmitMaterializeTemporaryExpr(clang::MaterializeTemporaryExpr const*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c476e6)
#11 0x000056061423ea5e clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c3ea5e)
#12 0x000056061424731d clang::CodeGen::CodeGenFunction::EmitReferenceBindingToExpr(clang::Expr const*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c4731d)
#13 0x00005606141d7b74 clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3bd7b74)
#14 0x00005606141d92bf clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const> >, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3bd92bf)
#15 0x000056061423ccf3 clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType, clang::CodeGen::CGCallee const&, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::Value*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c3ccf3)
#16 0x0000560614248ae8 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c48ae8)
#17 0x0000560614249fcb clang::CodeGen::RValue llvm::function_ref<clang::CodeGen::RValue (clang::CodeGen::ReturnValueSlot)>::callback_fn<(anonymous namespace)::AggExprEmitter::VisitCallExpr(clang::CallExpr const*)::'lambda'(clang::CodeGen::ReturnValueSlot)>(long, clang::CodeGen::ReturnValueSlot) CGExprAgg.cpp:0:0
#18 0x000056061424d49b (anonymous namespace)::AggExprEmitter::withReturnValueSlot(clang::Expr const*, llvm::function_ref<clang::CodeGen::RValue (clang::CodeGen::ReturnValueSlot)>) CGExprAgg.cpp:0:0
#19 0x000056061424d873 (anonymous namespace)::AggExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprAgg.cpp:0:0
#20 0x000056061424dc3b clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::AggExprEmitter, void>::Visit(clang::Stmt*) CGExprAgg.cpp:0:0
#21 0x0000560614250bc1 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c50bc1)
#22 0x000056061422f1fe clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c2f1fe)
#23 0x000056061422f8c9 clang::CodeGen::CodeGenFunction::EmitAnyExprToTemp(clang::Expr const*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c2f8c9)
#24 0x00005606141d7c5b clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&, clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3bd7c5b)
#25 0x00005606141d92bf clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const* const, clang::Stmt const* const> >, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3bd92bf)
#26 0x000056061423ccf3 clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType, clang::CodeGen::CGCallee const&, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::Value*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c3ccf3)
#27 0x0000560614248ae8 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c48ae8)
#28 0x0000560614285250 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#29 0x0000560614279bf3 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#30 0x0000560614279bdc (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#31 0x000056061427aa98 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#32 0x000056061427c2a3 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c7c2a3)
#33 0x0000560614235315 clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3c35315)
#34 0x0000560613fc7fb8 clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*, llvm::BasicBlock*, llvm::BasicBlock*, unsigned long, clang::Stmt::Likelihood) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x39c7fb8)
#35 0x0000560613f780d1 clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x39780d1)
#36 0x0000560613f72ad9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3972ad9)
#37 0x0000560613f7820e clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x397820e)
#38 0x0000560613f72ad9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3972ad9)
#39 0x0000560613f7852c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x397852c)
#40 0x0000560613fc8c43 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x39c8c43)
#41 0x0000560613fd273a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x39d273a)
#42 0x0000560614019198 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3a19198)
#43 0x00005606140162d5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3a162d5)
#44 0x0000560614016a13 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3a16a13)
#45 0x000056061401cdb1 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5387) CodeGenModule.cpp:0:0
#46 0x0000560614b70251 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#47 0x0000560614b64ef2 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x4564ef2)
#48 0x00005606159e41cc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x53e41cc)
#49 0x0000560614b6e1f2 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x456e1f2)
#50 0x000056061456ac41 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3f6ac41)
#51 0x00005606145053e2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x3f053e2)
#52 0x0000560614637013 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x4037013)
#53 0x00005606117afca4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x11afca4)
#54 0x00005606117abc5d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#55 0x00005606116ba5a7 main (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x10ba5a7)
#56 0x00007fe03b4b40b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#57 0x00005606117ab7da _start (/opt/compiler-explorer/clang-trunk-20220222/bin/clang-15+0x11ab7da)
clang-15: error: unable to execute command: Segmentation fault (core dumped)
clang-15: error: clang frontend command failed due to signal (use -v to see invocation)
Execution build compiler returned: 254
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 22, 2022

@llvm/issue-subscribers-c-20

@tbaederr
Copy link
Contributor

tbaederr commented Feb 22, 2022

Much reduced test case:

struct typeBase
{
  constexpr typeBase() : Lvalue() {}
  int Lvalue;
};

struct type : private typeBase
{
  bool value;
  type(bool v = 0) { value = v; }
  consteval type(int i) { value = i; }
  const bool operator*() const { return value; }
};

auto operator > (const type&a, const type&b) { return *a > *b; }

int main() {
  type T;
  if (T > type(100)) { }
}

And the assertion that fails is:

clang++: /home/tbaeder/code/llvm-project/llvm/lib/IR/Instructions.cpp:1491: void llvm::StoreInst::AssertOK(): Assertion `cast<PointerType>(getOperand(1)->getType()) ->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType()) && "Ptr must be a pointer to Val type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: bin/clang++ ./test.cpp -std=c++2a -c
1.	<eof> parser at end of file
2.	./test.cpp:23:5: LLVM IR generation of declaration 'main'
3.	./test.cpp:23:5: Generating code for declaration 'main'
(etc.)

Removing the consteval from the type(int i) constructor makes it work.

@tbaederr tbaederr added crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Feb 22, 2022
@AaronBallman
Copy link
Collaborator

I think this may be related to or a duplicate of #51764.

@AaronBallman AaronBallman added the confirmed Verified by a second party label Feb 22, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 22, 2022

@llvm/issue-subscribers-clang-codegen

@usx95 usx95 added the consteval C++20 consteval label Aug 20, 2022
@AaronBallman
Copy link
Collaborator

The reduced test case no longer crashes on trunk, but the original test case does still crash when emitting codegen.

@usx95
Copy link
Contributor

usx95 commented Sep 5, 2022

Reduce

struct Base {
    constexpr Base() : a(), b() {}
    char a : 1;
    char b;
};

struct Foo : private Base {
    constexpr Foo(bool b) {
        if (b) throw "test";
    }
};

struct Bar : private Base {
    consteval Bar(bool) {}
};

struct MyStruct {
    Foo foo = true;
    Bar bar = false;
};
MyStruct structTest;

https://godbolt.org/z/rxdP6YqMe

Does not crash if any of the following is true:

  • Foo::Foo(bool) does not throws. (Eg. Foo foo = false; in MyStruct)
  • Change char b to char b : 1 in Base.
  • Remove any member foo or bar from MyStruct.
  • Make Bar::Bar constexpr instead of consteval

@EugeneZelenko EugeneZelenko removed the crash Prefer [crash-on-valid] or [crash-on-invalid] label Sep 5, 2022
@luken-google luken-google self-assigned this Nov 28, 2022
@cor3ntin
Copy link
Contributor

This no longer crashes on trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

8 participants