MISRA Discussion Forums

Full Version: Difference between 2-10-2 and MISRA C-2012 Rule 5.3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

MISRA C-2012 Rule 5.3 (which is of the same title as 2-10-2) has this additional amplification about an identifier declared in an inner scope shall be distinct from *any* id declared in an outer scope.

So the following code shall be a violation for 5.3 although the inner "i" is not hiding the outer "i" (still confusing though).

Code:
void f() {
    {
        int i; // Non-compliant
    }
    int i;
}

Since 2-10-2 does not have this amplification, could you kindly help to advise whether this is also a violation for 2-10-2 or not?
It was not our intention to make the example you quote illegal, as there is no hiding involved.

We’ll pass you observation on to MISRA C