Boost C++ Libraries: Ticket #11323: is_virtual_base_of fails to build when virtual bases and their ancestors define identical virtual functions https://svn.boost.org/trac10/ticket/11323 <p> The following code snippet fails to build in clang 6.0: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/type_traits.hpp&gt; struct A { virtual void foo() {} }; struct B : public virtual A { virtual void foo() {} }; struct C : public B {}; int main() { std::cout &lt;&lt; boost::is_virtual_base_of&lt;B, C&gt;::value &lt;&lt; std::endl; return 0; } </pre><p> This is the compiler error it throws: </p> <pre class="wiki">/usr/local/include/boost/type_traits/is_virtual_base_of.hpp:55:12: error: virtual function 'A::foo' has more than one final overrider in 'boost_type_traits_internal_struct_X' struct boost_type_traits_internal_struct_X : public Derived, virtual Base (...) </pre><p> The problem can be temporarily worked around by redefining virtual void foo() {} into boost_type_traits_internal_struct_X, but that does not scale as we would need to know and override every single virtual method that appears both in A and B. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11323 Trac 1.4.3 John Maddock Wed, 20 May 2015 17:17:56 GMT <link>https://svn.boost.org/trac10/ticket/11323#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11323#comment:1</guid> <description> <p> That's nasty, as I assume this could be a common occurrence, but off the top of my head I don't see a way to fix this :( </p> <p> Will have to think on this. </p> </description> <category>Ticket</category> </item> <item> <author>leandro.gracia.gil@…</author> <pubDate>Wed, 20 May 2015 17:46:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11323#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11323#comment:2</guid> <description> <p> I don't see any either... I'll keep thinking too. </p> <p> BTW, in case somebody seeing this is wondering why we don't simply make foo a pure virtual in A and avoid the issue altogether, let me share a more meaningful example where this becomes a problem. </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/type_traits.hpp&gt; // Let's say enabling RTTI is not an option in our platform / project. #define ASSIGN_CLASS_ID() virtual int GetClassId() { return __COUNTER__; } struct A { ASSIGN_CLASS_ID(); }; struct B : public virtual A { ASSIGN_CLASS_ID(); }; struct C : public B { ASSIGN_CLASS_ID(); }; int main() { std::cout &lt;&lt; boost::is_virtual_base_of&lt;B, C&gt;::value &lt;&lt; std::endl; return 0; } </pre> </description> <category>Ticket</category> </item> <item> <author>douwegelling@…</author> <pubDate>Wed, 26 Oct 2016 12:39:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11323#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11323#comment:3</guid> <description> <p> Using apple LLVM 8.0.0, this fails with pure virtual base class as well: </p> <pre class="wiki"> #include &lt;iostream&gt; #include &lt;boost/type_traits.hpp&gt; struct A { virtual void foo() = 0; }; struct B : public virtual A { void foo() override {} }; struct C : public B {}; int main() { std::cout &lt;&lt; boost::is_virtual_base_of&lt;B, C&gt;::value &lt;&lt; std::endl; return 0; } </pre><p> fails to compile on my machine. This makes boost::serialize completely unusable in combination with virtual inheritance </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 12 May 2018 07:21:51 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11323#comment:4 https://svn.boost.org/trac10/ticket/11323#comment:4 <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> <p> Well it's only taken 3 years, but thanks to the "detection idiom" this should now be fixed in develop for all current (post C++11) compilers. </p> Ticket