Miscellaneous-NoAccessToGlobalsInXtorΒΆ
Avoid the use of global objects in constructors and destructors as they may not yet be initialized
Required inputs: IR
Example
int i = 0; // global object
class C {
C() { i = 10; } // bad - writing global i
~C() { int* p = &i; } // bad - potentially reading global i
void foo() { i++; } // ok - not accessed in constructor or destructor
}
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
access_global |
Avoid the use of global objects in constructors and destructors as they may not yet be initialized. |
None |
False |
Options
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
This rule has no individual options.