== Why is this an issue?

If a base class is both ``++virtual++`` and non-virtual in a multiple inheritance hierarchy then there will be at least two copies of the base class sub-object in the derived object. This may not be consistent with developer expectations.


=== Noncompliant code example

[source,cpp]
----
class A {};
class B1: public virtual A {};
class B2: public virtual A {};
class B3: public A {};
class C: public B1, B2, B3 {}; // Noncompliant, A is both virtual (through B1 and B2) and non-virtual (through B3)
----


=== Compliant solution

[source,cpp]
----
class A {};
class B1: public virtual A {};
class B2: public virtual A {};
class B3: public virtual A {};
class C: public B1, B2, B3 {}; // Compliant, A is always virtual
----


== Resources

* MISRA {cpp}:2008, 10-1-3 - An accessible base class shall not be both virtual and non-virtual in the same hierarchy.


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Class "xxx" derives from class "yyy" but lacks the "virtual" modifier.


'''
== Comments And Links
(visible only on this page)

=== on 16 Oct 2014, 13:25:29 Ann Campbell wrote:
\[~samuel.mercier] please:

* fill in the appropriate reference field(s).
* provide a See section.
* use double curly braces around code in the description

Since this is a "developer expectations" rule, I'd go with Reliability rather than maintainability, although I understand your thinking. However the rule of thumb on SQALE is that we go with the worst-case, and since unmet expectations imply that you'll get the wrong result: Reliability.

endif::env-github,rspecator-view[]
