MISRA Discussion Forums

Full Version: Does rule #15.3 apply to all blocks or only control blocks?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Suppose I have the following code:
Code:
void f()
{
    {
    goto L1;
    }
    {
L1:
    }
}

Does this code violate rule #15.3?
The Rule states that the label and the goto "shall be declared in the same block, or in any block enclosing the goto statement"

This rule applies to any block, not just control blocks.

The example cited is NON-COMPLIANT as label L1 is in a parallel block, not a block enclosing the goto.

Code:
void f()
{
    {
    goto L1;
    }
    {
L1:   /* Non-compliant */
    }
}