[LLVMbugs] [Bug 18780] Lambda inside lambda doesn't capture the variable

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Feb 9 02:48:42 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18780

jonathan.sauer at gmx.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jonathan.sauer at gmx.de
         Resolution|---                         |INVALID

--- Comment #2 from jonathan.sauer at gmx.de ---
The lambda function that is assigned to a->on_run captures on_create's
parameter <a> by reference instead of by value, i.e. it accesses a position in
the stack which can and will be reused later on. To test this add a function
<bar> that uses some stack space:

void bar()
{
  int s[] = { 1, 2, 3, 4, 5 };
}

and then call it before on_run:

  a.a = 1;
  bar();
  a.on_run();

Capturing <a> by value should make your code work as expected (it does on my
computer). Otherwise please feel free to reopen this bug.

-- 
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/20140209/2ae58403/attachment.html>


More information about the llvm-bugs mailing list