F.53: Fixed after review.

This commit is contained in:
psliwa 2016-02-24 13:37:43 +01:00
parent f11db25628
commit c680191bf9

View File

@ -3154,8 +3154,8 @@ Pointers and references to locals shouldn't outlive their scope. Lambdas that ca
{ {
int local = 42; int local = 42;
thread_pool.queue_work([&]{ process(local); }); // Want a reference to local. thread_pool.queue_work([&]{ process(local); }); // Want a reference to local.
// Note, that after program exists this scope, // Note, that after program exits this scope,
// local does no longer exist, therefore // local no longer exists, therefore
// process() call will have undefined behavior! // process() call will have undefined behavior!
} }
@ -3170,8 +3170,8 @@ Pointers and references to locals shouldn't outlive their scope. Lambdas that ca
##### Enforcement ##### Enforcement
* **Easy:** Warn, when capture-list contains a reference to a locally declared variable * (Simple) Warn when capture-list contains a reference to a locally declared variable
* **Medium:** Flag, when capture-list contains a reference to a locally declared variable and the lambda is passed to a non-`const` and non-local context * (Complex) Flag when capture-list contains a reference to a locally declared variable and the lambda is passed to a non-`const` and non-local context
### <a name="Rf-this-capture"></a>F.54: If you capture `this`, capture all variables explicitly (no default capture) ### <a name="Rf-this-capture"></a>F.54: If you capture `this`, capture all variables explicitly (no default capture)