MISRAC++2023-13.1.1
In this section:
Synopsis
(Advisory) Classes should not be inherited virtually
Enabled by default
No
Severity/Certainty
Low/High

Full description
Virtual inheritance introduces potentially confusing behaviour as call by dominance and base class initialization order changes This check is identical to MISRAC++2008-10-1-1.
Coding standards
- MISRA C++ 2008 10-1-1
(Advisory) Classes should not be derived from virtual bases.
Code examples
The following code example fails the check and will give a warning:
struct A
{
virtual int foo() { return 1; }
};
struct B : public virtual A // Non-compliant
{
int goo() { return foo(); }
};
The following code example passes the check and will not give a warning about this issue:
struct A
{
virtual int foo() { return 1; }
};
struct B : public A // Compliant
{
int goo() { return foo(); }
};