https://bugs.llvm.org/show_bug.cgi?id=50003

David Blaikie <dblai...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
                 CC|                            |dblai...@gmail.com
             Status|NEW                         |RESOLVED

--- Comment #1 from David Blaikie <dblai...@gmail.com> ---
Converting the lambda to a std::function doesn't change the type of the lambda.
The return type of the lambda is inferred by the type of the return statement
only.

Essentially the lambda this code creates is this:

auto unmentionable() {
  char t[10] = "abc";
  return t;
}
...
std::function<std::string()> f = unmentionable;

which results in a std::function that does something like this:

std::string func() {
  return unmentionable();
}

Because a char* is convertible to std::string, this ^ code compiles, but does
have the bug the diagnostic warns about - dangling pointer to a local variable.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to