Rule 11.9 : Global initialization of pointers

Moderators: misra-c, david ward

Post Reply
Akhil
Posts: 4
Joined: Mon Aug 12, 2013 10:12 am
Company: TCS

Rule 11.9 : Global initialization of pointers

Post by Akhil » Fri Mar 13, 2015 8:51 am

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. ?

misra-c
Posts: 571
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 11.9 : Global initialization of pointers

Post by misra-c » Fri Mar 27, 2015 1:21 pm

Rule 11.9 is not applicable to default initialisations. Your global declaration of "int *ptr;" does not violate rule 11.9.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.11 Pointer type conversions”