Difference between 2-10-2 and MISRA C-2012 Rule 5.3

Moderators: david ward, misra cpp

cxlin
Posts: 6
Joined: Tue May 12, 2015 1:24 am
Company: Red Lizard Software

Difference between 2-10-2 and MISRA C-2012 Rule 5.3

Postby cxlin » Wed Sep 19, 2018 7:04 am

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: Select all

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?

misra cpp
Posts: 135
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: Difference between 2-10-2 and MISRA C-2012 Rule 5.3

Postby misra cpp » Thu Oct 25, 2018 10:24 am

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
Posted by and on behalf of
the MISRA C++ Working Group


Return to “6.2 Lexical conventions (C++)”

Who is online

Users browsing this forum: No registered users and 0 guests