Boost C++ Libraries: Ticket #4394: assert in void_caster https://svn.boost.org/trac10/ticket/4394 <p> There is the static library with two classes, "base" and "derived". </p> <pre class="wiki">class base { public: base():a(0){}; virtual ~base(){}; private: friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { ar &amp; a; } private: int a; }; class derived: public base { public: derived():b(0){}; virtual ~derived(){}; private: friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { ar &amp; boost::serialization::base_object&lt;base&gt;(*this); ar &amp; b; } private: int b; }; </pre><p> This static library is linked to two dynamic libraries. For example, dll_a.dll and dll_b.dll. When I try to load those dlls in my application (via <a class="missing wiki">LoadLibrary</a>), I get assert in void_cast.cpp (225): </p> <pre class="wiki"> std::pair&lt;void_cast_detail::set_type::const_iterator, bool&gt; result; result = s.insert(this); assert(result.second); </pre><p> Sample project is available upon request. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4394 Trac 1.4.3 Robert Ramey Wed, 14 Jul 2010 05:22:11 GMT <link>https://svn.boost.org/trac10/ticket/4394#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4394#comment:1</guid> <description> <p> For now I'm going to comment out the assert. </p> <p> When I have time, I'll likely re-enable it with a way to override it. </p> <p> The problem is that the way the code is structured, you'll have multiple instances of some functions. The best way would be eliminate the source of the problem by structuring code like this: </p> <p> class base { public: </p> <blockquote> <p> base():a(0){}; virtual ~base(){}; </p> </blockquote> <p> private: </p> <blockquote> <p> friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version); </p> </blockquote> <p> private: </p> <blockquote> <p> int a; </p> </blockquote> <p> }; </p> <p> class derived: public base { public: </p> <blockquote> <p> derived():b(0){}; virtual ~derived(){}; </p> </blockquote> <p> private: </p> <blockquote> <p> friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version); </p> </blockquote> <p> private: </p> <blockquote> <p> int b; </p> </blockquote> <p> }; </p> <p> In dll_derived.cpp </p> <blockquote> <p> template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version){ { </p> <blockquote> <p> ar &amp; boost::serialization::base_object&lt;base&gt;(*this); ar &amp; b; </p> </blockquote> <p> } </p> </blockquote> <p> <em> instantiate for archives class used: </em></p> <p> template derived::serialize&lt;text_oarchive&gt;(text_oarchive, const unsigned int version); ... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Wed, 14 Jul 2010 05:23:52 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4394#comment:2 https://svn.boost.org/trac10/ticket/4394#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket 0xcdcdcdcd@… Tue, 13 Dec 2011 16:16:48 GMT <link>https://svn.boost.org/trac10/ticket/4394#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4394#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4394#comment:1" title="Comment 1">ramey</a>: </p> <blockquote class="citation"> <p> For now I'm going to comment out the assert. </p> <p> When I have time, I'll likely re-enable it with a way to override it. </p> <p> The problem is that the way the code is structured, you'll have multiple instances of some functions. The best way would be eliminate the source of the problem by structuring code like this: </p> </blockquote> <p> Hopefully we can generate some additional info via here: <a class="ext-link" href="http://permalink.gmane.org/gmane.comp.lib.boost.devel/226590"><span class="icon">​</span>http://permalink.gmane.org/gmane.comp.lib.boost.devel/226590</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>