AutosarC++18_03-M15.0.3

Control shall not be transferred into a try or catch block using a goto or a switch statement

Required inputs: IR

Rationale

A program is ill-formed if control is transferred into a try or catch block using a goto or switch statement; however, not all compilers issue a diagnostic message.

Example
void f ( int32_t i ) 
{
if ( 10 == i )
{
goto Label_10; // Non-compliant
}
if ( 11 == i )
{
goto Label_11; // Non-compliant
}
switch ( i )
{
case 1:
try
{
Label_10:
case 2: // Non-compliant – also violates switch rules
// Action
break;
} catch ( ... )
{
Label_11:
case 3: // Non-compliant – also violates switch rules
// Action
break;
}
break;
default:
{
// Default Action
break;
}
}
}

Note

For legal reasons, this rule’s description is not part of the public documentation.