[llvm-bugs] [Bug 42961] New: assertion failure converting lambda returning trivial_abi struct to function pointer
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Aug 11 21:22:58 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42961
Bug ID: 42961
Summary: assertion failure converting lambda returning
trivial_abi struct to function pointer
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: comexk at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
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.dylib`pthread_kill + 284
frame #2: 0x00007fff77c176a6 libsystem_c.dylib`abort + 127
frame #3: 0x00007fff77be020d libsystem_c.dylib`__assert_rtn + 324
frame #4: 0x000000010bdfc13b
libclangCodeGen.dylib`clang::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.dylib`clang::CodeGen::CodeGenFunction::EmitReturnOfRValue(this=0x00007ffeefbf84a8,
RV=RValue @ 0x00007ffeefbf7a40, Ty=QualType @ 0x00007ffeefbf7a38) at
CGStmt.cpp:1031:5
frame #6: 0x000000010bcca97a
libclangCodeGen.dylib`clang::CodeGen::CodeGenFunction::EmitForwardingCallToLambda(this=0x00007ffeefbf84a8,
callOperator=0x0000000124057a20, callArgs=0x00007ffeefbf7cc8) at
CGClass.cpp:2855:5
frame #7: 0x000000010bccb05d
libclangCodeGen.dylib`clang::CodeGen::CodeGenFunction::EmitLambdaDelegatingInvokeBody(this=0x00007ffeefbf84a8,
MD=0x0000000124057cc8) at CGClass.cpp:2917:3
frame #8: 0x000000010bccb1db
libclangCodeGen.dylib`clang::CodeGen::CodeGenFunction::EmitLambdaStaticInvokeBody(this=0x00007ffeefbf84a8,
MD=0x0000000124057cc8) at CGClass.cpp:2928:3
frame #9: 0x000000010c0d9179
libclangCodeGen.dylib`clang::CodeGen::CodeGenFunction::GenerateCode(this=0x00007ffeefbf84a8,
GD=GlobalDecl @ 0x00007ffeefbf83b0, Fn=0x0000000122404aa8,
FnInfo=0x00000001224037c0) at CodeGenFunction.cpp:1193:5
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190812/bb391c65/attachment-0001.html>
More information about the llvm-bugs
mailing list