Issue |
141242
|
Summary |
Clang assertion failure "Trying to aggregate-copy a type without a trivial copy/move constructor or assignment operator" in clang::CodeGen::CodeGenFunction::EmitAggregateCopy
|
Labels |
clang
|
Assignees |
|
Reporter |
alexfh
|
Some of our code exposes an assertion failure in Clang. I've reduced the example to this snippet:
```
template <class T>
class __attribute__((__trivial_abi__)) shared_ptr {
public:
shared_ptr(const shared_ptr&);
shared_ptr& operator=(const shared_ptr&);
};
class V {
shared_ptr<int> impl_;
};
V v();
void f() {
(void)+[] { return v(); };
}
```
The assertion failure is reproducible way back to Clang 7.
```
clang++: /root/llvm-project/llvm/tools/clang/lib/CodeGen/CGExprAgg.cpp:2297: void clang::CodeGen::CodeGenFunction::EmitAggregateCopy(clang::CodeGen::LValue, clang::CodeGen::LValue, clang::QualType, clang::CodeGen::AggValueSlot::Overlap_t, bool): Assertion `(Record->hasTrivialCopyConstructor() || Record->hasTrivialCopyAssignment() || Record->hasTrivialMoveConstructor() || Record->hasTrivialMoveAssignment() || Record->hasAttr<TrivialABIAttr>() || Record->isUnion()) && "Trying to aggregate-copy a type without a trivial copy/move " "constructor or assignment operator"' 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: /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. Per-file LLVM IR generation
3. <source>:12:10: Generating code for declaration 'f()::(anonymous class)::__invoke'
#0 0x0000000003fac638 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fac638)
#1 0x0000000003faa2c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3faa2c4)
#2 0x0000000003eeeef8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000070d14b042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000070d14b0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000070d14b042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000070d14b0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000070d14b02871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000070d14b039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000004323dc2 clang::CodeGen::CodeGenFunction::EmitAggregateCopy(clang::CodeGen::LValue, clang::CodeGen::LValue, clang::QualType, clang::CodeGen::AggValueSlot::Overlap_t, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4323dc2)
#10 0x000000000447f638 clang::CodeGen::CodeGenFunction::EmitReturnOfRValue(clang::CodeGen::RValue, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x447f638)
#11 0x00000000048826b2 clang::CodeGen::CodeGenFunction::EmitForwardingCallToLambda(clang::CXXMethodDecl const*, clang::CodeGen::CallArgList&, clang::CodeGen::CGFunctionInfo const*, llvm::Constant*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48826b2)
#12 0x00000000048834a6 clang::CodeGen::CodeGenFunction::EmitLambdaDelegatingInvokeBody(clang::CXXMethodDecl const*, clang::CodeGen::CallArgList&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48834a6)
#13 0x0000000004883903 clang::CodeGen::CodeGenFunction::EmitLambdaStaticInvokeBody(clang::CXXMethodDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4883903)
#14 0x000000000450f0ba clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x450f0ba)
#15 0x00000000045784ad clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45784ad)
#16 0x0000000004573634 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4573634)
#17 0x000000000457fe2c clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x457fe2c)
#18 0x000000000457fd48 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x457fd48)
#19 0x00000000045823b3 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45823b3)
#20 0x000000000495d6ce (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#21 0x0000000004959b05 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4959b05)
#22 0x000000000664a7fc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664a7fc)
#23 0x000000000495a298 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x495a298)
#24 0x0000000004c52cf5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c52cf5)
#25 0x0000000004bd10fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bd10fe)
#26 0x0000000004d44d19 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d44d19)
#27 0x0000000000dae7af cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdae7af)
#28 0x0000000000da53ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x00000000049c13a9 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
#30 0x0000000003eef394 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eef394)
#31 0x00000000049c19bf 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
#32 0x000000000498378d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x498378d)
#33 0x000000000498481e 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+++0x498481e)
#34 0x000000000498cb05 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x498cb05)
#35 0x0000000000daacbf clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdaacbf)
#36 0x0000000000c304c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc304c4)
#37 0x000070d14b029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#38 0x000070d14b029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#39 0x0000000000da4e75 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda4e75)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs