MISRA C++:2023 Rule 13.1.1
Description
Rule Definition
Classes should not be inherited virtually. 1
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
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.