Boost C++ Libraries: Ticket #10310: serialization/smart_cast.hpp uses dynamic_cast and breaks non-RTTI builds https://svn.boost.org/trac10/ticket/10310 <p> When serializing through a pointer to a polymorphic base class, dynamic cast is invoked in line 204, thus making it impossible to serialize via base pointer without RTTI. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10310 Trac 1.4.3 Robert Ramey Mon, 04 Aug 2014 15:24:56 GMT <link>https://svn.boost.org/trac10/ticket/10310#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10310#comment:1</guid> <description> <p> I am very interested in address this as well as you're related observation regarding collections helper. I think both of these are fixable - but not as easily as one might think. </p> <p> I've always wanted the serialization library to be usable in a non-RTTI environment and included code to permit this. Unfortunately, I only included one test to verify this. This test actually verifies the ability of types using different systems to inter operate. Since you're actually using this, you might want to make a couple of tests to catch these kinds of errors. If you do this, please follow the schema for the current tests which can be applied to any archive type. This would make it much easier for me to incorporate such tests. I would hope that just a few such tests would give the the assurance that the serialization library would be useful in a non-RTTI environment. </p> <p> It's also possible that creation of these tests would uncover a couple of "gotchas" which should be described in the documentation. We can incorporate that as well - if necessary a new section for this special case. </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <author>Mika Fischer <mika.fischer@…></author> <pubDate>Tue, 05 Aug 2014 08:00:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10310#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10310#comment:2</guid> <description> <p> Well, with 1.55.0, the existing test case (test_no_rtti.cpp) already triggers this bug (and <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8400" title="#8400: Bugs: Serialization uses typeid in shared_ptr helper even when compileing ... (closed: fixed)">#8400</a>) <em>if it is compiled without RTTI</em>. So getting the existing test case to work when RTTI is disabled in the compiler would probably go a long way towards fixing the existing issues with RTTI. </p> <p> I'm pretty sure <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10280" title="#10280: Bugs: archive/detail/helper_collection.hpp uses typeid and breaks non-RTTI builds (closed: fixed)">#10280</a> is also triggered by the test case, but with 1.56.0, it does not compile for me </p> <pre class="wiki">% g++ test_no_rtti.cpp polymorphic_{base.cpp,derived1.cpp,derived2.cpp} /shared/distlibs/dists/arch-glibc2.19-gcc4.9.1-x86_64/boost_1_56_0/lib/libboost_{serialization.a,system.a,filesystem.a} /tmp/cc15E2ee.o: In function `boost::archive::text_iarchive::text_iarchive(std::istream&amp;, unsigned int)': test_no_rtti.cpp:(.text._ZN5boost7archive13text_iarchiveC2ERSij[_ZN5boost7archive13text_iarchiveC5ERSij]+0x36): undefined reference to `boost::archive::detail::shared_ptr_helper::shared_ptr_helper()' /tmp/cc15E2ee.o: In function `boost::archive::text_iarchive::~text_iarchive()': test_no_rtti.cpp:(.text._ZN5boost7archive13text_iarchiveD2Ev[_ZN5boost7archive13text_iarchiveD5Ev]+0x24): undefined reference to `boost::archive::detail::shared_ptr_helper::~shared_ptr_helper()' collect2: error: ld returned 1 exit status </pre><p> We have decided not to pursue boost serialization without RTTI any further at this time. Buf if you have specific questions or requests, I'll see what I can do to help. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 05 Aug 2014 19:09:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10310#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10310#comment:3</guid> <description> <p> I'm totally convinced of this. test_no_rtti isn't really named correctly. I tests the inter operability of classes using differing type identification systems. In order to test this it chooses two systems to use in the test - and one of them is rtti. </p> <p> "When serializing through a pointer to a polymorphic base class, dynamic cast is invoked in line 204, thus making it impossible to serialize via base pointer without RTTI." </p> <p> line 204 - but which file? </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 05 Aug 2014 19:12:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10310#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10310#comment:4</guid> <description> <p> btw - I've fixed the helper collection issue on my local machine. Will check in after some more testing. </p> </description> <category>Ticket</category> </item> <item> <author>Mika Fischer <mika.fischer@…></author> <pubDate>Wed, 06 Aug 2014 08:17:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10310#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10310#comment:5</guid> <description> <p> Well, I guess my point is that no additional tests are necessary. The existing test just needs to be compiled without RTTI to catch all relevant bugs. </p> <p> The dynamic_cast is invoked in serialization/smart_cast.hpp:204 in 1.55.0 and also in master on github. </p> </description> <category>Ticket</category> </item> </channel> </rss>