Skip to content

assertion failure converting lambda returning trivial_abi struct to function pointer #42306

@comex

Description

@comex
Bugzilla Link 42961
Resolution FIXED
Resolved on Jun 22, 2021 21:16
Version trunk
OS All
Blocks #48661
CC @aeubanks,@DougGregor,@DimitryAndric,@zygoloid,@tstellar
Fixed by commit(s) c8227f0 6c57bab

Extended Description

I think the fix may be to just change the assert in EmitAggregateCopy, as memcpying a trivial_abi return value should work.

Test case:


struct A {
A(A &);
A &operator=(const A &);
} attribute((trivial_abi));
A (*f)() = -> A {};


$ clang -cc1 -triple x86_64-apple-macosx10.14.0 -S test.cpp

Assertion failed: ((Record->hasTrivialCopyConstructor() || Record->hasTrivialCopyAssignment() || Record->hasTrivialMoveConstructor() || Record->hasTrivialMoveAssignment() || Record->isUnion()) && "Trying to aggregate-copy a type without a trivial copy/move " "constructor or assignment operator"), function EmitAggregateCopy, file /usr/src/llvm/clang/lib/CodeGen/CGExprAgg.cpp, line 1928.

(lldb) bt

  • thread #​1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    • frame #​0: 0x00007fff77cad2a6 libsystem_kernel.dylib__pthread_kill + 10 frame #​1: 0x00007fff77d68bf1 libsystem_pthread.dylibpthread_kill + 284
      frame #​2: 0x00007fff77c176a6 libsystem_c.dylibabort + 127 frame #​3: 0x00007fff77be020d libsystem_c.dylib__assert_rtn + 324
      frame #​4: 0x000000010bdfc13b libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitAggregateCopy(this=0x00007ffeefbf84a8, Dest=LValue @ 0x00007ffeefbf76b0, Src=LValue @ 0x00007ffeefbf7710, Ty=QualType @ 0x00007ffeefbf7698, MayOverlap=DoesNotOverlap, isVolatile=false) at CGExprAgg.cpp:1922:7 frame #​5: 0x000000010c03dd03 libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitReturnOfRValue(this=0x00007ffeefbf84a8, RV=RValue @ 0x00007ffeefbf7a40, Ty=QualType @ 0x00007ffeefbf7a38) at CGStmt.cpp:1031:5
      frame #​6: 0x000000010bcca97a libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitForwardingCallToLambda(this=0x00007ffeefbf84a8, callOperator=0x0000000124057a20, callArgs=0x00007ffeefbf7cc8) at CGClass.cpp:2855:5 frame #​7: 0x000000010bccb05d libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitLambdaDelegatingInvokeBody(this=0x00007ffeefbf84a8, MD=0x0000000124057cc8) at CGClass.cpp:2917:3
      frame #​8: 0x000000010bccb1db libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitLambdaStaticInvokeBody(this=0x00007ffeefbf84a8, MD=0x0000000124057cc8) at CGClass.cpp:2928:3 frame #​9: 0x000000010c0d9179 libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::GenerateCode(this=0x00007ffeefbf84a8, GD=GlobalDecl @ 0x00007ffeefbf83b0, Fn=0x0000000122404aa8, FnInfo=0x00000001224037c0) at CodeGenFunction.cpp:1193:5

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillac++

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions