Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/boost/archive/detail/interface_iarchive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ template<class Archive>
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:
/////////////////////////////////////////////////////////
Expand Down
16 changes: 16 additions & 0 deletions include/boost/archive/detail/interface_oarchive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ template<class Archive>
class interface_oarchive
{
protected:
#if defined(_MSC_VER)

@jmairboeck jmairboeck Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initally wanted to add the following:

Suggested change
#if defined(_MSC_VER)
#if defined(_MSC_VER) && _MSC_VER == 1952

because Microsoft said they are already working on a fix, but for supporting linking different versions together, we can't be that specific I guess. But the following should work:

Suggested change
#if defined(_MSC_VER)
#if defined(_MSC_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000

Other versions (older ones) are not ABI compatible anyway and can't be linked together with the affected version. Maybe the minimum version can even be increased to 1950.

The same change needs also be done in the other file.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would that change buy?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not adding the member unnecessarily for older MSVC versions (before 2015 in the _MSC_VER == 1900 case).

// 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
// <https://developercommunity.visualstudio.com/t/C-object-layout-places-empty-non-first/11175160>
// and <https://github.com/boostorg/serialization/issues/389>.
//
// 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:
/////////////////////////////////////////////////////////
Expand Down
Loading