The following (simplified) code trying to wrap a lambda gives me a warning with some Clang versions, but not all and not gcc.
template<typename Lambda>
auto wrapLambda(Lambda lambda)
{
return [&lambda]() {
lambda();
};
}
auto wrappedLambda = wrapLambda([](){ return 0; });
warning: address of stack memory associated with parameter 'lambda' returned [-Wreturn-stack-address]
return [&lambda]() {
^~~~~~
Is this a bug, or am I missing something? I'm getting the warning with x86-64 clang (trunk)
in godbolt and clang version 11.1.0
as part of a larger repo, but I haven't been able to isolate the failure with that version.
The example in this related question doesn't give the warning.
Aucun commentaire:
Enregistrer un commentaire