Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Does rule #15.3 apply to all blocks or only control blocks?
#1
Suppose I have the following code:
Code:
void f()
{
    {
    goto L1;
    }
    {
L1:
    }
}

Does this code violate rule #15.3?
Reply
#2
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 */
    }
}
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)