Commit 86b2ff29 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Avoid gcc7 bug in SerialExecutor test

Summary:
[Folly] Avoid gcc7 lambda-captures bug in `SerialExecutor` test.

```
folly/executors/test/SerialExecutorTest.cpp: In lambda function:
folly/executors/test/SerialExecutorTest.cpp:66:40: error: declaration of 'i' shadows a previous local [-Werror=shadow]
folly/executors/test/SerialExecutorTest.cpp:60:12: note: shadowed declaration is here
folly/executors/test/SerialExecutorTest.cpp: In function 'void simpleTest(const std::shared_ptr<folly::Executor>&)':
folly/executors/test/SerialExecutorTest.cpp:74:45: error: already captured 'i' in lambda expression [-Werror]
folly/executors/test/SerialExecutorTest.cpp: In lambda function:
folly/executors/test/SerialExecutorTest.cpp:74:62: error: 'i' is not captured
folly/executors/test/SerialExecutorTest.cpp:74:46: note: the lambda has no capture-default
folly/executors/test/SerialExecutorTest.cpp:60:12: note: 'int i' declared here
```

Fixes #1154.

Reviewed By: andriigrynenko

Differential Revision: D15629657

fbshipit-source-id: fec82e9d54b2c79a7f54f366ec8a19ad7dc198e9
parent 59ca4e5c
...@@ -63,7 +63,7 @@ void simpleTest(std::shared_ptr<folly::Executor> const& parent) { ...@@ -63,7 +63,7 @@ void simpleTest(std::shared_ptr<folly::Executor> const& parent) {
SerialExecutorContextData::kCtxKey(), SerialExecutorContextData::kCtxKey(),
std::make_unique<SerialExecutorContextData>(i)); std::make_unique<SerialExecutorContextData>(i));
folly::RequestContextScopeGuard ctxGuard(ctx); folly::RequestContextScopeGuard ctxGuard(ctx);
static auto checkReqCtx = [](auto i) { auto checkReqCtx = [i] {
EXPECT_EQ( EXPECT_EQ(
i, i,
dynamic_cast<SerialExecutorContextData*>( dynamic_cast<SerialExecutorContextData*>(
...@@ -71,8 +71,8 @@ void simpleTest(std::shared_ptr<folly::Executor> const& parent) { ...@@ -71,8 +71,8 @@ void simpleTest(std::shared_ptr<folly::Executor> const& parent) {
SerialExecutorContextData::kCtxKey())) SerialExecutorContextData::kCtxKey()))
->getId()); ->getId());
}; };
executor->add([i, g = folly::makeGuard([i] { checkReqCtx(i); }), &values] { executor->add([i, checkReqCtx, g = folly::makeGuard(checkReqCtx), &values] {
checkReqCtx(i); checkReqCtx();
// make this extra vulnerable to concurrent execution // make this extra vulnerable to concurrent execution
values.push_back(0); values.push_back(0);
burnMs(10); burnMs(10);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment