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
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));
}