From 7b8c8076b423a403b7601ced72ba7b0a4ffebd4e Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Fri, 22 Jul 2016 10:13:42 -0700 Subject: [PATCH] Use decltype to get the type of a non-static local Summary: As the `sizeof()` is being evaluated in a static context, MSVC doesn't let you reference non-static locals. Solve the issue by getting the type of the local via `decltype` instead. Reviewed By: yfeldblum Differential Revision: D3600845 fbshipit-source-id: 825d93ced8f09d9f4bf0dcf02142f47a0ec32605 --- folly/io/async/test/AsyncSSLSocketTest.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/folly/io/async/test/AsyncSSLSocketTest.h b/folly/io/async/test/AsyncSSLSocketTest.h index 42bb03ac..384198d1 100644 --- a/folly/io/async/test/AsyncSSLSocketTest.h +++ b/folly/io/async/test/AsyncSSLSocketTest.h @@ -1085,8 +1085,9 @@ class SSLClient : public AsyncSocket::ConnectCallback, // socket, even if the maxReadsPerEvent_ is hit during // a event loop iteration. static constexpr size_t kMaxReadsPerEvent = 2; + // 2 event loop iterations static constexpr size_t kMaxReadBufferSz = - sizeof(readbuf_) / kMaxReadsPerEvent / 2; // 2 event loop iterations + sizeof(decltype(readbuf_)) / kMaxReadsPerEvent / 2; public: SSLClient(EventBase *eventBase, -- 2.34.1