Does 5.6 or 5.7 apply to block scope identifiers?

6.5 Identifiers

Moderators: misra-c, david ward

Locked
gs
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

Does 5.6 or 5.7 apply to block scope identifiers?

Post by gs » Thu May 15, 2008 4:30 pm

The rule reads:
No identifier name should be reused.

Regardless of scope, no identifier should be re-used across any files in the system. This rule incorporates the provisions of Rules 5.2, 5.3, 5.4, 5.5 and 5.6.
Does this advisory apply to block scope variables? The accompanying text says the rule incorporates the provisions of the other rules, but does not say if the rule is limited to just those provisions.

Rule 5.7 appears to constitute a stricter version of rule 5.6, which raises the question, "Does 5.6 apply to block scope variables?" as well.

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

Re: Does 5.6 or 5.7 apply to block scope identifiers?

Post by misra-c » Wed May 21, 2008 1:58 pm

Both Rules 5.6 and 5.7 apply to block scope.
---
Posted by and on behalf of
the MISRA C Working Group

gs
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

Re: Does 5.6 or 5.7 apply to block scope identifiers?

Post by gs » Thu May 22, 2008 4:29 pm

So, code like this is non-compliant?

Code: Select all

void f(void)
    {
    int i;
    }

void g(void)
    {
    int i;
    }

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

Re: Does 5.6 or 5.7 apply to block scope identifiers?

Post by misra-c » Wed Sep 24, 2008 9:05 am

The following code is not compliant with advisory Rule 5.7.

Code: Select all

void f(void)
    {
    int i;
    }

void g(void)
    {
    int i;
    }
---
Posted by and on behalf of
the MISRA C Working Group

Locked

Return to “6.5 Identifiers”