Thank you very much for your reply Gavin.  This is what we had assumed after all our tests and we have now the confirmation.

I am just wondering if it will be valuable to explain this corner case in the Boost.Serialization documentation. 

Best regards,

Marc

Le lun. 7 mars 2022 à 01:34, Gavin Lambert via Boost-users <boost-users@lists.boost.org> a écrit :
On 6/03/2022 00:21, Marc Viala wrote:
> On our platform (VS2019, Windows x64, Boost 1.77) an exception occurs
> during the serialization of an instance through its base pointer. This
> error is systematic and I was able to reproduce w/ a minimal use test
> (cf. enclosed archive). This use case includes a solution w/ a DLL
> project and EXE project. The EXE project is a simple unit-test. On my
> platform  when I execute the executable, I trigger an exception from
> Boost.Serialization ("unregistered void cast class cpe::derived_t<-class
> cpe::object_t"). I tried every recommandation that we can find on SO and
> Boost mailing lists without success. To be accurate, I prefer to mention
> that we are using Boost.Serialization Static Library flavor.

This last sentence is the cause of your problem.

If you wish to use static libraries, then you must use *only* static
libraries (or at least anything that is in a static library cannot
appear in your DLL ABI at all).

If you wish to use Boost.Serialization in your DLL ABI then you must use
the shared library variant only, such that both your EXE and DLL use a
common implementation.  Otherwise they will each have independent copies
of the singletons.

If your DLL boundary exists only for unit testing, then switch your DLL
to a static library instead.  If it exists for consuming by applications
other than just your unit test, then you have to ensure that Boost types
and concepts do not cross the DLL boundary if you want to use them as a
static library.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users


--
Marc Viala