Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC++2023-9.6.3

In this section:
Synopsis

(Required) The goto statement shall jump to a label declared later in the function body

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

A goto statement is declared after the destination label. This check is identical to MISRAC++2008-6-6-2, MISRAC2012-Rule-15.2.

Coding standards
MISRA C:2012 Rule-15.2

(Required) The goto statement shall jump to a label declared later in the same function

MISRA C++ 2008 6-6-2

(Required) The goto statement shall jump to a label declared later in the same function body.

Code examples

The following code example fails the check and will give a warning:

void f1 ( )
{
  int j = 0;
  for ( j = 0; j < 10 ; ++j )
  {
L1: // Non-compliant
    j;
  }
  goto L1;
}

The following code example passes the check and will not give a warning about this issue:

void f1 ( )
{
  int j = 0;
  goto L1;
  for ( j = 0; j < 10 ; ++j )
  {
    j;
  }
L1:
  return;
}