MISRAC++2023-13.1.2 (C++ only)
In this section:
Synopsis
(Required) An accessible base class shall not be both virtual and non-virtual in the same hierarchy
Enabled by default
Yes
Severity/Certainty
Medium/High

Full description
This makes it confusing whether the intent is to have the base object instantiated one or more times. This check is identical to MISRAC++2008-10-1-3.
Coding standards
- MISRA C++ 2008 10-1-3
(Required) An accessible base class shall not be both virtual and non-virtual in the same hierarchy.
Code examples
The following code example fails the check and will give a warning:
class A {};
class B: public virtual A {};
class C: public A,B {}; // Non-compliant
The following code example passes the check and will not give a warning about this issue:
class A {};
class B: public virtual A {};
class C: public virtual A, B {}; // Compliant