Commit 8a4545ed authored by Michael Connor's avatar Michael Connor Committed by Jordan DeLong

Initialize variable before using in own initialization

Summary:
Clang throws error because the callback refers to itself inside its lambda
function definition.  I prevent this by declaring the variable first then the
compiler does not complain when it is used within its lambda definition.

folly/test/TimeoutQueueTest.cpp:99:37: error: variable 'cb' is uninitialized
when used within its own initialization [-Werror,-Wuninitialized]

Test Plan:
fbconfig --clang --platform=gcc-4.7.1-glibc-2.14.1 --with-project-version
boost:1.51.0 folly/test/
fbmake opt
fbmake runtests_opt

Reviewed By: ldbrandy@fb.com

FB internal diff: D753061
parent 5e3674ca
......@@ -93,8 +93,8 @@ TEST(TimeoutQueue, RunOnceRepeating) {
TEST(TimeoutQueue, RunOnceReschedule) {
int count = 0;
TimeoutQueue q;
TimeoutQueue::Callback cb =
[&count, &q, &cb](TimeoutQueue::Id id, int64_t now) {
TimeoutQueue::Callback cb;
cb = [&count, &q, &cb](TimeoutQueue::Id id, int64_t now) {
if (++count < 100) {
EXPECT_LT(id, q.add(now, 0, cb));
}
......
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