Boost C++ Libraries: Ticket #3730: compilation problem with is_virtual_base_of when class contains abstract methods https://svn.boost.org/trac10/ticket/3730 <p> When a virtual base class contains an abstract method that is implemented in the inheritance tree, rather than the final class, gcc won't compile serialized classes. This happens with gcc 4.3.1 on openSuSE 11.0 and gcc 4.4.1 on 11.2. </p> <p> I'm attaching a modified version of the test_diamond.cpp program from the serialization library. The base class now contains an abstract method, the final class in the example has been renamed to intermediate and a new final class is derived directly from intermediate. The abstract method is implemented in the intermediate class resulting in a compiler error<br /> /usr/local/boost-<a class="changeset" href="https://svn.boost.org/trac10/changeset/58233/include/boost/type_traits/is_virtual_base_of" title="config file parser now stores original_tokens, Fixes #2727">r58233/include/boost/type_traits/is_virtual_base_of</a>.hpp:56: error: no unique final overrider for ‘virtual void base::method1()’ in ‘boost::detail::is_virtual_base_of_impl&lt;intermediate, final, mpl_::bool_&lt;true&gt; &gt;::X’<br /> The method looks to be unique to me. If the method is implemented in final rather than intermediate then the problem doesn't occur. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3730 Trac 1.4.3 Barry Searle <barry.searle@…> Tue, 08 Dec 2009 12:53:41 GMT attachment set https://svn.boost.org/trac10/ticket/3730 https://svn.boost.org/trac10/ticket/3730 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_diamond2.cpp</span> </li> </ul> <p> example program to reproduce problem </p> Ticket John Maddock Tue, 08 Dec 2009 16:22:13 GMT <link>https://svn.boost.org/trac10/ticket/3730#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3730#comment:1</guid> <description> <p> I can't at present see a way to fix this, here's a reduced test case: </p> <pre class="wiki"> #include &lt;map&gt; #include &lt;iostream&gt; #include &lt;boost/type_traits.hpp&gt; class base { public: base() : i(0) {} base(int i) : i(i) { m[i] = "text"; } virtual void method1() = 0; virtual ~base() {}; private: int i; std::map&lt;int, std::string&gt; m; }; class derived1 : virtual public base { public: }; class derived2 : virtual public base { public: }; class intermediate : public derived1, public derived2 { public: intermediate() {} intermediate(int i) : base(i) {} void method1(); }; void intermediate::method1() { } class final : public intermediate { public: final() {} final(int i) : base(i) {} }; // // This class demonstrates what we need to make work inside is_virtual_base_of. // MSVC compiles this just fine (likewise is_virtual_base_of), and only complains // when attempting to use method1. Other compilers (GCC, Intel on Linux) complain // as soon as X is declared, likewise when instantiating is_virtual_base_of. // struct X : final, virtual intermediate { X(); X(const X&amp;); X&amp; operator=(const X&amp;); ~X()throw(); }; int main( int /* argc */, char* /* argv */[] ) { X x; x.method1(); boost::is_virtual_base_of&lt;intermediate, final&gt;::type t; return t.value != true; } </pre> </description> <category>Ticket</category> </item> <item> <author>manfred.doudar@…</author> <pubDate>Fri, 29 Jan 2010 01:41:52 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/3730#comment:2 https://svn.boost.org/trac10/ticket/3730#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">manfred.doudar@…</span> added </li> </ul> <p> Since Final inherits from Intermediate, and X from both - you in effect have a "diamond" since X can take a path either through Final or Intermediate. In which case: </p> <blockquote> <p> class final : public virtual intermediate </p> </blockquote> <p> should resolve matters, no? </p> Ticket John Maddock Thu, 06 Jan 2011 11:30:35 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3730#comment:3 https://svn.boost.org/trac10/ticket/3730#comment:3 <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">wontfix</span> </li> </ul> <p> Class Final is defined outside our control - that's the issue - I'm closing this as "unfixable" for now. </p> Ticket barry.searle@… Mon, 10 Jan 2011 12:25:05 GMT <link>https://svn.boost.org/trac10/ticket/3730#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3730#comment:4</guid> <description> <p> What happens next? will it be removed from release versions of the library? or modified so it at least compiles? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 10 Jan 2011 12:57:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3730#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3730#comment:5</guid> <description> <p> Nothing happens next - unless someone can come up with a fix - as far as anyone can tell it's simply not possible to make the trait work in every possible case like this - since the trait isn't part of the next std the only solution for occational difficult cases like this, is for the user to supply a specialisation of is_virtual_base_of. </p> <p> HTH, John. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Mon, 10 Jan 2011 13:19:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3730#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3730#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/67912" title="Document the restrictions on is_virtual_base_of. Refs #3730.">[67912]</a>) Document the restrictions on is_virtual_base_of. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3730" title="#3730: Bugs: compilation problem with is_virtual_base_of when class contains ... (closed: wontfix)">#3730</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Mon, 10 Jan 2011 13:23:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3730#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3730#comment:7</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/67913" title="Document the restrictions on is_virtual_base_of. Refs #3730.">[67913]</a>) Document the restrictions on is_virtual_base_of. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3730" title="#3730: Bugs: compilation problem with is_virtual_base_of when class contains ... (closed: wontfix)">#3730</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Mon, 10 Jan 2011 16:55:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3730#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3730#comment:8</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/67916" title="Document the restrictions on is_virtual_base_of. Refs #3730.">[67916]</a>) Document the restrictions on is_virtual_base_of. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3730" title="#3730: Bugs: compilation problem with is_virtual_base_of when class contains ... (closed: wontfix)">#3730</a>. </p> </description> <category>Ticket</category> </item> </channel> </rss>