...
Code Block | ||||
---|---|---|---|---|
| ||||
class B1 { int val; public: B1(int val) : val(val) {} }; class B2 { int otherVal; public: B2(int otherVal) : otherVal(otherVal) {} }; class D : B1, B2 { public: D(int a) : B1(a), B2(a) {} }; |
Exceptions
OOP53-CPP-EX0: Constructors that do not use member initializers do not violate this rule. Anchor OOP53-EX0 OOP53-EX0
Risk Assessment
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
OOP53-CPP | Medium | Unlikely | Medium | P4 | L3 |
Automated Detection
Tool | Version | Checker | Description |
---|
Astrée |
|
|
|
4053, 4056, 4058
initializer-list-order | Fully checked | ||||||||
Axivion Bauhaus Suite |
| CertC++-OOP53 | |||||||
Clang |
| -Wreorder |
CodeSonar |
| LANG.STRUCT.INIT.OOMI | Out of Order Member Initializers | ||||||
Helix QAC |
| C++4053 | |||||||
Klocwork |
| CERT.OOP.CTOR.INIT_ORDER | |||||||
LDRA tool suite |
| 206 S | Fully implemented | ||||||
Parasoft C/C++test |
| CERT_CPP-OOP53-a | List members in an initialization list in the order in which they are declared | |||||||
Polyspace Bug Finder |
| CERT C++: OOP53-CPP | Checks for members not initialized in canonical order (rule fully covered) | ||||||
RuleChecker |
| initializer-list-order | Fully checked |
SonarQube C/C++ Plugin |
| S3229 |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Bibliography
[ISO/IEC 14882-2014] | Subclause 12.6.2, "Initializing Bases and Members" |
[Lockheed Martin 2005] | AV Rule 75, Members of the initialization list shall be listed in the order in which they are declared in the class |
...
...