24-10-2022, 08:50 PM
found this in the parasoft docs...reposting without permission.
All member variables should be initialized in constructor [AUTOSAR-A12_1_1-b]
DESCRIPTION
Constructors of 'class' and 'struct' should initialize all member variables.
The rule checks if a member variable is initialized:
- in constructor initialization list
- inside body of constructor
- inside body of function called from constructor (three levels of nested
function's calls are checked)
- directly in class (C++11).
If there is no constructor at all a violation is reported for 'class' only.
You can enable INIT-15 to get a violation for 'struct' too.
See also: INIT-10, INIT-14, INIT-15, MISRA-030
NOTES
The rule assumes that member variable might be initialized
by passing its non-const pointer to an external function.
Member variables which are static or have class or struct type are ignored.
Static variables should not be initialized in constructor.
Class/struct variables are assumed to be initialized by their own constructors.
If in constructor is called default copy assignment operator,
then the rule assumes that all member variables are initialized.
If in constructor is called a member function from the current class with
non-accessible body, then this rule assumes that all member variables are
initialized.
BENEFITS
Prevents reading from uninitialized variables.
All member variables should be initialized in constructor [AUTOSAR-A12_1_1-b]
DESCRIPTION
Constructors of 'class' and 'struct' should initialize all member variables.
The rule checks if a member variable is initialized:
- in constructor initialization list
- inside body of constructor
- inside body of function called from constructor (three levels of nested
function's calls are checked)
- directly in class (C++11).
If there is no constructor at all a violation is reported for 'class' only.
You can enable INIT-15 to get a violation for 'struct' too.
See also: INIT-10, INIT-14, INIT-15, MISRA-030
NOTES
The rule assumes that member variable might be initialized
by passing its non-const pointer to an external function.
Member variables which are static or have class or struct type are ignored.
Static variables should not be initialized in constructor.
Class/struct variables are assumed to be initialized by their own constructors.
If in constructor is called default copy assignment operator,
then the rule assumes that all member variables are initialized.
If in constructor is called a member function from the current class with
non-accessible body, then this rule assumes that all member variables are
initialized.
BENEFITS
Prevents reading from uninitialized variables.