diff --git a/include/boost/archive/detail/interface_iarchive.hpp b/include/boost/archive/detail/interface_iarchive.hpp index 18e5cb1cc..474823447 100644 --- a/include/boost/archive/detail/interface_iarchive.hpp +++ b/include/boost/archive/detail/interface_iarchive.hpp @@ -34,6 +34,10 @@ template class interface_iarchive { protected: + #if defined(_MSC_VER) + // See the same member of interface_oarchive. + char m_msvc_14_52_workaround; + #endif interface_iarchive() {} public: ///////////////////////////////////////////////////////// diff --git a/include/boost/archive/detail/interface_oarchive.hpp b/include/boost/archive/detail/interface_oarchive.hpp index 8a2017345..7cd2ee1cc 100644 --- a/include/boost/archive/detail/interface_oarchive.hpp +++ b/include/boost/archive/detail/interface_oarchive.hpp @@ -36,6 +36,22 @@ template class interface_oarchive { protected: + #if defined(_MSC_VER) + // MSVC 14.52, unlike earlier versions, converts a pointer to an empty + // base which ends its derived class with an offset one less than the + // layout says, so a static library and a program built by different + // versions disagree on where the archive is. This member keeps the + // base from being empty. Microsoft has fixed the bug for a later + // release, so the member can be removed once 14.52 is no longer in + // use; see + // + // and . + // + // Note that we test _MSC_VER, not BOOST_MSVC: clang-cl and the Intel + // compiler define it too, and as they use the same layout as MSVC and + // link with libraries built by it, they must agree on the member. + char m_msvc_14_52_workaround; + #endif interface_oarchive() {} public: /////////////////////////////////////////////////////////