Commit 1cd3b037 authored by Wez Furlong's avatar Wez Furlong Committed by Facebook Github Bot

folly: fixup AsyncTimeoutTest on windows

Summary:
In D14702587 I made a change to workaround an ICE in gcc 8.
It turns out to be a gift that keeps giving; with the code as-is
on windows we now encounter:

```
folly\io\async\test\AsyncTimeoutTest.cpp(29): error C3493: 'expected' cannot be implicitly captured because no default capture mode has been specified
```

Adding `expected` to the capture list yields this error with gcc, either with or without the reference:

```
stderr: folly/io/async/test/AsyncTimeoutTest.cpp:29:45: error: lambda capture 'expected' is not required to be captured for this use [-Werror,-Wunused-lambda-capture]
      AsyncTimeout::make(manager, [&value, &expected]() noexcept { value = expected; });
                                         ~~~^~~~~~~~
1 error generated.
```

the solution is to make `expected` not be `const`.

Reviewed By: yfeldblum

Differential Revision: D14721418

fbshipit-source-id: b65c17414c161b9dee7f269b2e2a22a980766a6c
parent e8e6817c
......@@ -22,11 +22,11 @@ namespace folly {
TEST(AsyncTimeout, make) {
int value = 0;
int const expected = 10;
int expected = 10;
EventBase manager;
auto observer =
AsyncTimeout::make(manager, [&value]() noexcept { value = expected; });
auto observer = AsyncTimeout::make(
manager, [&value, expected ]() noexcept { value = expected; });
observer->scheduleTimeout(std::chrono::milliseconds(100));
......@@ -37,11 +37,11 @@ TEST(AsyncTimeout, make) {
TEST(AsyncTimeout, schedule) {
int value = 0;
int const expected = 10;
int expected = 10;
EventBase manager;
auto observer = AsyncTimeout::schedule(
std::chrono::milliseconds(100), manager, [&value]() noexcept {
std::chrono::milliseconds(100), manager, [&value, expected ]() noexcept {
value = expected;
});
......@@ -52,11 +52,11 @@ TEST(AsyncTimeout, schedule) {
TEST(AsyncTimeout, schedule_immediate) {
int value = 0;
int const expected = 10;
int expected = 10;
EventBase manager;
auto observer = AsyncTimeout::schedule(
std::chrono::milliseconds(0), manager, [&value]() noexcept {
std::chrono::milliseconds(0), manager, [&value, expected ]() noexcept {
value = expected;
});
......@@ -66,11 +66,11 @@ TEST(AsyncTimeout, schedule_immediate) {
TEST(AsyncTimeout, cancel_make) {
int value = 0;
int const expected = 10;
int expected = 10;
EventBase manager;
auto observer =
AsyncTimeout::make(manager, [&value]() noexcept { value = expected; });
auto observer = AsyncTimeout::make(
manager, [&value, expected ]() noexcept { value = expected; });
std::weak_ptr<RequestContext> rctx_weak_ptr;
......@@ -92,7 +92,7 @@ TEST(AsyncTimeout, cancel_make) {
TEST(AsyncTimeout, cancel_schedule) {
int value = 0;
int const expected = 10;
int expected = 10;
EventBase manager;
std::unique_ptr<AsyncTimeout> observer;
std::weak_ptr<RequestContext> rctx_weak_ptr;
......@@ -102,9 +102,9 @@ TEST(AsyncTimeout, cancel_schedule) {
rctx_weak_ptr = RequestContext::saveContext();
observer = AsyncTimeout::schedule(
std::chrono::milliseconds(100), manager, [&value]() noexcept {
value = expected;
});
std::chrono::milliseconds(100),
manager,
[&value, expected ]() noexcept { value = expected; });
observer->cancelTimeout();
}
......
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