Detecting unhandled cases in switch statements
Description
Checks for a missing case label in a switch statement that does not have a default label.
Why perform the check
The check is useful, for example, to detect when an enum type has been augmented with a new value that is not yet handled in a switch statement.
How to use it
Compiler option: ‑‑runtime_checking switch
In the IDE: Project>Options>Runtime Checking>Switch
The check can be applied to one or more modules.
The check can be avoided by adding a default label.
How it works
The compiler inserts an implicit default label to perform the check in each switch statement that does not have a default label.
Example
Follow the procedure described in Getting started using C-RUN runtime error checking, but use the Switch option.
This is an example of source code that will be identified during runtime:
C-RUN will report Unhandled case in switch. This is an example of the message information that will be listed: