[LLVMbugs] [Bug 15512] New: Clang generates invalid code when lambdas call lambdas.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Mar 14 08:29:56 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=15512
Bug ID: 15512
Summary: Clang generates invalid code when lambdas call
lambdas.
Product: clang
Version: trunk
Hardware: PC
OS: Windows XP
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: ian.stewart at autodesk.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 10179
--> http://llvm.org/bugs/attachment.cgi?id=10179&action=edit
template workaround to avoid nested lambda bags.
I have created a simple program that crashes when running the resulting code
generated by Clang.
int main( int argc, char *argv[])
{
auto first = [&]() { return argc; };
auto second = [&]() { return first(); };
return second();
}
I have investigated a little, and what I have found is that Clang mistakenly
thinks that 'first' and 'second' should have the same implementation, only
generates code for one of them, yet calls it for both.
If I change the resulting type of 'first' to differ from 'second', it works:
int main( int argc, char *argv[])
{
auto first = [&]() -> unsigned int { return argc; };
auto second = [&]() -> int { return first(); };
return second();
}
As an ugly workaround, forcing a different return type using a templated
wrapper works (see attachment)
LLVM 3.3 @ SVN 176884
clang++.exe -Xclang -cxx-abi -Xclang microsoft -S -emit-llvm lambdafail.cpp -o
lambdafail.cpp.bc
lli.exe lambdafail.cpp.bc x y
expected result: 3
Reply from Richard Smith <richard at metafoo.co.uk> on the mailing list:
The implementation of the Microsoft ABI is incomplete. It's quite likely that
it does not correctly mangle lambdas yet.
--
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/20130314/01676908/attachment.html>
More information about the llvm-bugs
mailing list