Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
langcpp
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

Anchor
OOP53-EX0
OOP53-EX0
OOP53-CPP-EX0: Constructors that do not use member initializers do not violate this rule.

Risk Assessment

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

OOP53-CPP

Medium

Unlikely

Medium

P4

L3

Automated Detection

Tool

Version

Checker

Description

PRQA QA-C++
Astrée

Include Page

Astrée_V
Astrée

PRQA QA-C++

_V

PRQA QA-C++
initializer-list-order
Fully checked
Axivion Bauhaus Suite

Include Page
Axivion Bauhaus Suite_V

4053

 

Axivion Bauhaus Suite_V

CertC++-OOP53
Clang
Include Page
Clang_V
Clang_V
-Wreorder
 

CodeSonar
Include Page
CodeSonar_V
CodeSonar_V

LANG.STRUCT.INIT.OOMI

Out of Order Member Initializers

Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C++4053
Klocwork
Include Page
Klocwork_V
Klocwork_V
CERT.OOP.CTOR.INIT_ORDER
LDRA tool suite
Include Page
LDRA_V
LDRA_V

206 S

Fully implemented

Parasoft C/C++test
9.5INIT-10
Include Page
Parasoft_V
Parasoft_V

CERT_CPP-OOP53-a

List members in an initialization list in the order in which they are declared
Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C++: OOP53-CPPChecks for members not initialized in canonical order (rule fully covered)
RuleChecker
Include Page
RuleChecker_V
RuleChecker_V
initializer-list-order
Fully checked
 
SonarQube C/C++ Plugin
Include Page
SonarQube C/C++ Plugin_V
SonarQube C/C++ Plugin_V
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

...


...

Image Modified Image Modified Image Modified