[cfe-dev] Clang generates invalid code when lambdas call lambdas.
Richard Smith
richard at metafoo.co.uk
Wed Mar 13 16:31:55 PDT 2013
On Wed, Mar 13, 2013 at 3:37 PM, Ian Stewart <Ian.Stewart at autodesk.com>wrote:
> Hello,
>
> 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();
> }
>
> 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
>
The implementation of the Microsoft ABI is incomplete. It's quite likely
that it does not correctly mangle lambdas yet.
> expected result: 3
>
> Thank you,
> Ian
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130313/ec446e41/attachment.html>
More information about the cfe-dev
mailing list