I debugged things on Linux, good news:
You work at bullet no. 3 from Jeremy Pak's post :
RTTI does not always work as expected across DLL boundaries. Check out the type_info classes to find out how I deal with this.
I have a tiny patch to fix (below) to boost/extension/impl/typeinfo.hpp (but you need to talk to the Boost Extension developer, really). This is independent of the built-in comparison for the RTTI type.
Looking at typeinfo.hpp, it seems that Windows never uses type comparison info, so I decided to test using the backup method 'strcmp' and voila:
$ LD_LIBRARY_PATH=. ./Simple-Inheritance Creating an animal using factory: Cougar factory Created an animal: cougar Age: 2 Creating an animal using factory: Leopard factory Created an animal: leopard Age: 3 Creating an animal using factory: Puma factory Created an animal: puma Age: 4 Creating an animal using factory: Wildcat factory Created an animal: wildcat Age: 5
In particular, I can show that the type search from convertible_ not performed on the type_map.hpp line, line 68;
- When this conversion is called from the innermost dll library, the conversion happily finds a match using RTTI.
- However, when the "same" .get () is executed from the test application (across the boundaries of the DLL, i.e.) the RTTI is different and such a match is not found, and line 74/75 is hit:
.
73 if (it == instances_.end()) { 74 holder = new type_holder<StoredType>; 75 it = instances_.insert(std::make_pair(t, holder)).first; 76 }
Patch
diff --git a/Boost.Extension.Tutorial/libs/boost/extension/impl/typeinfo.hpp b/Boost.Extension.Tutorial/libs/boost/extension/impl/typeinfo.hpp index 843fed2..09fc353 100644 --- a/Boost.Extension.Tutorial/libs/boost/extension/impl/typeinfo.hpp +++ b/Boost.Extension.Tutorial/libs/boost/extension/impl/typeinfo.hpp @@ -50,7 +50,7 @@ struct type_info_handler<default_type_info, ClassType> // This list should be expanded to all platforms that successfully // compare type_info across shared library boundaries. -#if defined(__APPLE__) || defined(__GNUC__) || \ +#if defined(__APPLE__) || \ defined(BOOST_EXTENSION_FORCE_FAST_TYPEINFO) namespace boost { namespace extensions { @@ -90,7 +90,7 @@ inline bool operator>(const default_type_info& first, }
sehe Apr 30 2018-11-11T00: 00Z
source share