[Bug c++/60096] c++11 lambda reference capture mistake

feng.wang@uni-ulm.de gcc-bugzilla@gcc.gnu.org
Thu Feb 6 14:45:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60096

--- Comment #2 from Feng Wang <feng.wang@uni-ulm.de> ---
(In reply to Jonathan Wakely from comment #1)
> This looks invalid to me, you return a closure that holds a dangling
> reference to a function parameter that has gone out of scope.

Sorry, my fault. I should have been using a const reference

[]( int const& x )        
{
  return [&x](int const& y)
  {
    return x+y;
  };
}                  
(2)(5);



More information about the Gcc-bugs mailing list