Main Content
MISRA C++:2023 Rule 13.1.1
Description
Rule Definition
Classes should not be inherited virtually.
Rationale
While virtual inheritance helps to solve the diamond inheritance problem, the use of virtual base classes can introduce confusing behavior. For example, during name resolution, a method in a derived class can hide methods with the same name in base classes further up the inheritance hierarchy, which might result in a call to a function with the wrong number of arguments
Polyspace Implementation
The coding rule checker reports a violation for any class that inherits virtually from a base class.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Derived classes |
Category: Advisory |
Version History
Introduced in R2024b