MISRA Discussion Forums
Does 5.6 or 5.7 apply to block scope identifiers? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.5 Identifiers (https://forum.misra.org.uk/forumdisplay.php?fid=32)
+---- Thread: Does 5.6 or 5.7 apply to block scope identifiers? (/showthread.php?tid=518)



Does 5.6 or 5.7 apply to block scope identifiers? - gs - 15-05-2008

The rule reads:
Quote: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.


Re: Does 5.6 or 5.7 apply to block scope identifiers? - misra-c - 21-05-2008

Both Rules 5.6 and 5.7 apply to block scope.


Re: Does 5.6 or 5.7 apply to block scope identifiers? - gs - 22-05-2008

So, code like this is non-compliant?
Code:
void f(void)
    {
    int i;
    }

void g(void)
    {
    int i;
    }



Re: Does 5.6 or 5.7 apply to block scope identifiers? - misra-c - 24-09-2008

The following code is not compliant with advisory Rule 5.7.
Code:
void f(void)
    {
    int i;
    }

void g(void)
    {
    int i;
    }