JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
The ordering in the member initializer list for a class constructor does not match the order in which the initializers will be invoked.
The order of invocation for member initializers is specified in the C++ standard and is independent of their order in the initializer list. A warning of this class is issued if a constructor for class C is invoked at least once in the analyzed code but the member initializer list for the constructor does not meet all of the following requirements.
A member initializer list that does not reflect this ordering may cause confusion for human readers.
| Class Name | Out of Order Member Initializers | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | style | |||||||||||||||
| Mnemonic | LANG.STRUCT.INIT.OOMI | |||||||||||||||
| Categories |
|
|||||||||||||||
| Availability | Available for C++ only (not C). |
|||||||||||||||
| Enabling | Checks for this warning class are enabled by default.
However, warning instances of this class that are issued as parser
errors (rather than parser warnings)
will be discarded
when using factory configuration settings.
To prevent these instances from being discarded, add the
following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Out of Order Member Initializers" WARNING_FILTER += discard class="Out of Order Member Initializers" |
namespace lang_struct_init_oomi{
class VirtualBase {
public:
VirtualBase(void): second_int(1),
first_int(2) {}; // 'Out of Order Member Initializers' warning issued here
VirtualBase(int i){}
private:
int first_int;
int second_int;
};
class FirstClass {
public:
FirstClass(void){}
FirstClass(int i){}
};
class SecondClass {
public:
SecondClass(void){}
SecondClass(int i){}
};
class Derived: virtual VirtualBase, FirstClass, SecondClass {
public:
Derived(void) : mychar('x'),
FirstClass(1), // 'Out of Order Member Initializers' warning issued here
VirtualBase(2) {}
Derived(int i) : SecondClass(i),
FirstClass(i) {} // 'Out of Order Member Initializers' warning issued here
Derived(char c) : VirtualBase(1), // ok:
FirstClass(1), // all initializer list ordering requirements
SecondClass(1), // met for this constructor
mychar(c) {}
private:
char mychar;
};
Derived d1; // invokes Derived::Derived(void)
Derived d2(2); // invokes Derived::Derived(int i), which in turn invokes VirtualBase::VirtualBase(void)
Derived d3('c'); // invokes Derived::Derived(char c)
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.