Skip to content

Misra.md: the switch without default is a deviation (9.4.2) - #112

Merged
theAndreas merged 1 commit into
mainfrom
misra-9-4-2-deviation
Nov 17, 2026
Merged

theAndreas merged 1 commit into
mainfrom
misra-9-4-2-deviation

Conversation

@theAndreas

Copy link
Copy Markdown
Owner

What

docs/Misra.md of a project records the switch over an enum class without default as a deviation from MISRA C++:2023 Rule 9.4.2, with its reason. The row now also says in part: the rest of the structure of a switch, as where its labels stand and how many branches it has, is left to review.

Why

CodingStyle T-15 asks for that switch to have no default, so that -Wswitch reports a value added to the enum later, which a default would take in unnoticed. The rule asks for a default in every switch but one over an unscoped enum without a fixed type. The row named T-15 as if it covered the rule, where it departs from it.

How it was checked

  • tests/check.sh lint docs passes for the Arduino library and with --no-arduino; tests/doc_indent.py passes.
  • Only Misra.md and the CHANGELOG change; no code, no check.

CodingStyle T-15 leaves out the default of a switch over an enum class, so
that -Wswitch reports a value added to the enum later, which a default would
take in unnoticed; the rule asks for one. The row named T-15 as if it
covered the rule. It now records the departure with its reason, and says
that the rest of the structure of a switch, as where its labels stand and
how many branches it has, is left to review.
@theAndreas
theAndreas merged commit cc3349c into main Nov 17, 2026
1 check passed
@theAndreas
theAndreas deleted the misra-9-4-2-deviation branch November 17, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants