MISRA Discussion Forums

Full Version: Rule 11.9 : Global initialization of pointers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In this case :

1. int *ptr ; // Is this compliant or non compliant
2. void foo()
3. {
4. /* Do Something. */
5. }

Global variables are initialized to 0 by default.
This means ptr is initialized to 0 automatically by compiler.

Ques : Is line 1 compliant or non compliant to Rule 11.9.

Does this rule also enforce initializing ptr to NULL for global pointers. ?
Rule 11.9 is not applicable to default initialisations. Your global declaration of "int *ptr;" does not violate rule 11.9.