AUTOSAR C++14 Rule A12-1-6
Derived classes that do not need further explicit initialization and require all the constructors from the base class shall use inheriting constructors
Since R2020b
Description
Rule Definition
Derived classes that do not need further explicit initialization and require all the constructors from the base class shall use inheriting constructors.
Rationale
If a derived class uses all the base class constructors and does not explicitly initialize any additional data member that is not in the base class, reimplementing these constructors in the derived class adds unnecessary lines of code. The reimplementation might not exactly match the constructors in the base class due to human error and might introduce bugs in your code. Moreover, every time you change the base class constructors, you must also update the derived class constructors. This increases the overhead of code maintenance.
In such situations, using inheriting constructors in the derived class solves these issues.
Polyspace Implementation
Polyspace flags a class for violation of this rule if the class satisfies all of these conditions:
The class derives from a single base class.
The class uses all the base class constructors and reimplements them in the class definition.
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: Special member functions |
Category: Required, Automated |
Version History
Introduced in R2020b