Main Content

Check for switch case expressions without a default case

Check ID: mathworks.misra.SwitchDefault

Identify switch case expressions that do not have a default case.


The check flags model objects that have switch case expressions without a default case.

Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications, as well as code that complies with the CERT C, CWE, ISO/IEC TS 17961 standards.

The check does not flag blocks without default cases if they are justified with a Polyspace® annotation. When you run the check, the Blocks with justification table lists blocks without default cases that have a justification.

Available with Embedded Coder® and Simulink® Check™.

Results and Recommended Actions

ConditionRecommended Action

Model object has a switch case expression without a default case.

For Switch Case blocks, consider selecting block parameter Show default case to explicitly specify a default case.

Capabilities and Limitations

You can:

  • Run this check on your library models.

  • Exclude blocks and charts from this check if you have a Simulink Check license.

Edit-Time Checking

This check is supported by edit-time checking.

See Also