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

            Bug ID: 15365
           Summary: Capturing a const reference parameter by value in
                    lambda fails to correctly generate
                    constructor/destructor calls of captured value
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Created attachment 10082
  --> http://llvm.org/bugs/attachment.cgi?id=10082&action=edit
Reproduces the bug

Compile attached file with
clang++ -std=c++11 -stdlib=libc++ TestFunctional.cpp -o TestFunctional

The relevant function:

void Capture(std::function<void (CDispatchTypeTag *)> const &_Function)
{
  //auto Function = _Function; // Uncomment this and it works
  auto fTest
    = [_Function]()
    {
      _Function(nullptr);
    }
  ;
}

The destructor and copy constructor is not called the correct number of times
unless the line above is uncommented.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to