AUTOSAR C++14 Rule M15-0-3
Control shall not be transferred into a try or catch block using a goto or a switch statement
Description
Rule Definition
Control shall not be transferred into a try or catch block using a goto or a switch statement.
Rationale
Transferring control into a try
or catch
block by
using a goto
or a switch
statement results in
ill-formed code that is difficult to understand. The intended behavior of such code is
difficult to identify and the code might result in unexpected behavior. Abruptly entering
into an exception handling block might cause compilation failure in some compilers while
other compilers might not diagnose the issue. To improve code understanding and reduce
unexpected behavior, avoid transferring control into a try or a catch block.
Polyspace Implementation
Polyspace® flags the goto
and switch
statements
that jump into a try
or a catch
block.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Exception Handling |
Category: Required, Automated |
Version History
Introduced in R2019a