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

consteval constructor causes "Assertion `cast<PointerType>(getOperand(1)->getType()) ->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType()) && "Ptr must be a pointer to Val type!"' failed" #51764

Closed
stbergmann opened this issue Nov 5, 2021 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category confirmed Verified by a second party worksforme Resolved as "works for me"

Comments

@stbergmann
Copy link
Collaborator

Bugzilla Link 52422
Version trunk
OS Linux
CC @AaronBallman,@zygoloid

Extended Description

At least with clang-13.0.0~rc1-1.fc35.x86_64 and with recent Clang 14 trunk,

$ cat test.cc
struct S {
consteval S() {}
union {
int a;
struct { int b; } c = {0};
};
};
void f() { S(); }

clang++ -std=c++20 -c test.cc
test.cc:8:12: warning: expression result unused [-Wunused-value]
void f() { S(); }
^~~
clang++: llvm/lib/IR/Instructions.cpp:1492: void llvm::StoreInst::AssertOK(): Assertion `cast(getOperand(1)->getType()) ->isOpaqueOrPointeeTypeMatches(getOperand(0)->getType()) && "Ptr must be a pointer to Val type!"' failed.
[...]
#​7 0x00007fe1bbcf07d3 abort (/lib64/libc.so.6+0x2c7d3)
#​8 0x00007fe1bbcf06fb _nl_load_domain.cold (/lib64/libc.so.6+0x2c6fb)
#​9 0x00007fe1bbcff3a6 (/lib64/libc.so.6+0x3b3a6)
#​10 0x00000000021bf9a2 llvm::Align::Align(unsigned long) llvm/include/llvm/Support/Alignment.h:78:5
#​11 0x00000000021bf9a2 llvm::StoreInst::getAlign() const llvm/include/llvm/IR/Instructions.h:354:12
#​12 0x00000000021bf9a2 llvm::StoreInst::getAlignment() const llvm/include/llvm/IR/Instructions.h:351:42
#​13 0x00000000021bf9a2 llvm::StoreInst::AssertOK() llvm/lib/IR/Instructions.cpp:1493:3
#​14 0x00000000021bfb8f llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, llvm::Align, llvm::Instruction*) llvm/lib/IR/Instructions.cpp:1517:7
#​15 0x0000000000a28250 llvm::Twine::Twine(char const*) llvm/include/llvm/ADT/Twine.h:170:14
#​16 0x0000000000a28250 llvm::IRBuilderBase::CreateAlignedStore(llvm::Value*, llvm::Value*, llvm::MaybeAlign, bool) llvm/include/llvm/IR/IRBuilder.h:1757:12
#​17 0x0000000002e7fd93 clang::CodeGen::CodeGenFunction::EmitAggregateStore(llvm::Value*, clang::CodeGen::Address, bool) clang/lib/CodeGen/CGCall.cpp:1316:61
#​18 0x0000000002ef5a44 (anonymous namespace)::AggExprEmitter::VisitConstantExpr(clang::ConstantExpr*) clang/lib/CodeGen/CGExprAgg.cpp:0:11
#​19 0x0000000002efac8c (anonymous namespace)::AggExprEmitter::VisitCastExpr(clang::CastExpr*) clang/lib/CodeGen/CGExprAgg.cpp:0:0
#​20 0x0000000002ef0737 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) clang/lib/CodeGen/CGExprAgg.cpp:108:3
#​21 0x0000000002ef0737 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) clang/lib/CodeGen/CGExprAgg.cpp:2000:49
#​22 0x0000000002ed0e80 clang::CodeGen::AggValueSlot::isIgnored() const clang/lib/CodeGen/CGValue.h:620:17
#​23 0x0000000002ed0e80 clang::CodeGen::AggValueSlot::asRValue() const clang/lib/CodeGen/CGValue.h:640:9
#​24 0x0000000002ed0e80 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) clang/lib/CodeGen/CGExpr.cpp:214:20
#​25 0x0000000002ed0d49 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) clang/lib/CodeGen/CGExpr.cpp:196:1
#​26 0x0000000002c593a5 llvm::IRBuilderBase::GetInsertBlock() const llvm/include/llvm/IR/IRBuilder.h:178:47
#​27 0x0000000002c593a5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) clang/lib/CodeGen/CGStmt.cpp:123:42
#​28 0x0000000002c6511c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) clang/lib/CodeGen/CGStmt.cpp:468:22
#​29 0x0000000002cbebae clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) clang/lib/CodeGen/CodeGenFunction.cpp:0:5
[...]

@AaronBallman
Copy link
Collaborator

AaronBallman commented Nov 9, 2021

This requires an assertions build to reproduce. https://godbolt.org/z/7eaKxG3eW Full stack trace is:

clang++: /root/llvm-project/llvm/lib/IR/Instructions.cpp:1492: 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://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-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 -std=c++20 <source>
1.	<eof> parser at end of file
2.	<source>:9:6: LLVM IR generation of declaration 'f'
3.	<source>:9:6: Generating code for declaration 'f'
 #&#8203;0 0x00005574438d39bf PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #&#8203;1 0x00005574438d17b0 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38d17b0)
 #&#8203;2 0x0000557443815648 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #&#8203;3 0x00007f4881e563c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #&#8203;4 0x00007f488192518b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
 #&#8203;5 0x00007f4881904859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
 #&#8203;6 0x00007f4881904729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
 #&#8203;7 0x00007f4881915f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #&#8203;8 0x0000557442fedc8e llvm::StoreInst::AssertOK() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x2fedc8e)
 #&#8203;9 0x0000557442fede93 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, llvm::Align, llvm::Instruction*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x2fede93)
#&#8203;10 0x0000557443eadbe5 clang::CodeGen::CodeGenFunction::EmitAggregateStore(llvm::Value*, clang::CodeGen::Address, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eadbe5)
#&#8203;11 0x0000557443f3a1f3 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#&#8203;12 0x0000557441191f71 (anonymous namespace)::AggExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprAgg.cpp:0:0
#&#8203;13 0x0000557443f39efb (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#&#8203;14 0x0000557443f3aa2e clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f3aa2e)
#&#8203;15 0x0000557443f1757f clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f1757f)
#&#8203;16 0x0000557443f32cce clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f32cce)
#&#8203;17 0x0000557443c54e0a clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c54e0a)
#&#8203;18 0x0000557443c5a8fc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c5a8fc)
#&#8203;19 0x0000557443ca9006 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ca9006)
#&#8203;20 0x0000557443cb97ac clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cb97ac)
#&#8203;21 0x0000557443d058b1 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d058b1)
#&#8203;22 0x0000557443d021b5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d021b5)
#&#8203;23 0x0000557443d0295b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d0295b)
#&#8203;24 0x0000557443d09022 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.6661) CodeGenModule.cpp:0:0
#&#8203;25 0x00005574449118fd (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#&#8203;26 0x000055744490619e clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x490619e)
#&#8203;27 0x00005574457d6c04 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x57d6c04)
#&#8203;28 0x000055744490ebd8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x490ebd8)
#&#8203;29 0x000055744423ab61 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x423ab61)
#&#8203;30 0x00005574441d704a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41d704a)
#&#8203;31 0x000055744430a983 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x430a983)
#&#8203;32 0x0000557441319c4c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1319c4c)
#&#8203;33 0x0000557441315049 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#&#8203;34 0x0000557444087c25 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
#&#8203;35 0x0000557443815c33 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3815c33)
#&#8203;36 0x0000557444089fa4 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-assertions-trunk/bin/clang+++0x4089fa4)
#&#8203;37 0x000055744405fb6a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x405fb6a)
#&#8203;38 0x00005574440607ff clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40607ff)
#&#8203;39 0x00005574440695ba clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40695ba)
#&#8203;40 0x0000557441241ddf main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1241ddf)
#&#8203;41 0x00007f48819060b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#&#8203;42 0x0000557441314bba _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1314bba)
clang-14: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
This was referenced Feb 22, 2022
@xgupta
Copy link
Contributor

xgupta commented Jun 27, 2022

This requires an assertions build to reproduce. https://godbolt.org/z/7eaKxG3eW Full stack trace is:

Checked today, it is fine and not crashing anymore.

@xgupta xgupta closed this as completed Jun 27, 2022
@EugeneZelenko EugeneZelenko added the worksforme Resolved as "works for me" label Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category confirmed Verified by a second party worksforme Resolved as "works for me"
Projects
None yet
Development

No branches or pull requests

5 participants