Explicit vtordisp for MSVC
[folly.git] / folly / io / async / AsyncSocket.h
index de1ca7893ce9389294b9fcb6d9bfe5942b9af3f6..28c553a5f82683a39476e15a2833fb173dc02321 100644 (file)
@@ -61,6 +61,13 @@ namespace folly {
  * responding and no further progress can be made sending the data.
  */
 
+#ifdef _MSC_VER
+// We do a dynamic_cast on this, in
+// AsyncTransportWrapper::getUnderlyingTransport so be safe and
+// force displacements for it. See:
+// https://msdn.microsoft.com/en-us/library/7sf3txa8.aspx
+#pragma vtordisp(push, 2)
+#endif
 class AsyncSocket : virtual public AsyncTransportWrapper {
  public:
   typedef std::unique_ptr<AsyncSocket, Destructor> UniquePtr;
@@ -818,6 +825,8 @@ class AsyncSocket : virtual public AsyncTransportWrapper {
 
   BufferCallback* bufferCallback_{nullptr};
 };
-
+#ifdef _MSC_VER
+#pragma vtordisp(pop)
+#endif
 
 } // folly