From 2446a692e47c00a843a5d8025323cabbf81a9f0f Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Fri, 7 Aug 2026 15:32:20 +0200 Subject: [PATCH] Don't derive the archive exceptions virtually `archive_exception` derived virtually from `std::exception`, and `xml_archive_exception` from `archive_exception` in turn, which gives both classes an implicit vbase destructor. MSVC and Clang disagree about whether the DLL owns that function or the consumer: cl never exports it and lets every consumer synthesize its own, while clang-cl exports it with the class and imports it. Therefore, a program built with clang-cl against a library built with cl failed to link. Since virtual inheritance didn't buy much here, this removes it, leaving nothing for the two compilers to disagree about. Fixes #321. --- include/boost/archive/archive_exception.hpp | 5 ++++- include/boost/archive/xml_archive_exception.hpp | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/boost/archive/archive_exception.hpp b/include/boost/archive/archive_exception.hpp index e95b6f15e..0e9dddff6 100644 --- a/include/boost/archive/archive_exception.hpp +++ b/include/boost/archive/archive_exception.hpp @@ -39,8 +39,11 @@ namespace archive { ////////////////////////////////////////////////////////////////////// // exceptions thrown by archives // +// The base is deliberately not virtual: a virtual one would give the +// class an implicit vbase destructor, which cl and clang-cl expect to +// find in different modules. See issue #321. class BOOST_SYMBOL_VISIBLE archive_exception : - public virtual std::exception + public std::exception { private: char m_buffer[128]; diff --git a/include/boost/archive/xml_archive_exception.hpp b/include/boost/archive/xml_archive_exception.hpp index 66be31f70..0ebb0a2ce 100644 --- a/include/boost/archive/xml_archive_exception.hpp +++ b/include/boost/archive/xml_archive_exception.hpp @@ -31,8 +31,10 @@ namespace archive { ////////////////////////////////////////////////////////////////////// // exceptions thrown by xml archives // +// The base is deliberately not virtual, for the reason given in +// archive_exception.hpp. See issue #321. class BOOST_SYMBOL_VISIBLE xml_archive_exception : - public virtual boost::archive::archive_exception + public boost::archive::archive_exception { public: typedef enum {