Main Content

MISRA C:2023 Rule 16.6

Every switch statement shall have at least two switch-clauses

Since R2024a

Description

Rule Definition

Every switch statement shall have at least two switch-clauses.

Rationale

A switch statement with a single path is redundant and can indicate a programming error.

Troubleshooting

If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Check Information

Group: Switch Statements
Category: Required
AGC Category: Advisory

Version History

Introduced in R2024a