1.5.4. Migration to 7.12.4¶
1.5.4.1. Stylechecks¶
FaultDetection-DeadBranches¶
We reworked the detection of constant conditions and dead branches for C/C++:
Conditions and subexpressions that the compiler folds to constants during translation (for example, uses of enumerators,
sizeofcomparisons, or conditions in template instances) are now also reported.Findings are now reported at the constant (sub)expression itself or at the short-circuiting operator determined by it. Generic findings that duplicated a specialized finding for the same expression are no longer reported.
Constant conditions and subexpressions in the initializers of global variables are now also reported; the initialization and finalization code for global variables was previously excluded from the check.
Expressions in contexts that grammatically require constant expressions (for example,
static_assertdeclarations, case labels, array bounds, bit-field widths, enumerator initializations, non-type template arguments, initializers ofconstexprvariables, andnoexceptspecifications) are no longer reported.Two message keys were added and are enabled by default:
dead_param_dependent_var_true_branch_type_limitsanddead_param_dependent_var_false_branch_type_limits. They report conditions on variables whose values depend on a parameter and are constant due to the limited range of a data type, complementing the existingdead_param_dependent_var_true_branchanddead_param_dependent_var_false_branchmessage keys.Two options were added and are enabled by default:
ignore_literal_subexpressionsexempts literal operands of short-circuiting operators inside conditions, such asassert(false && "message"), from subexpression findings, andignore_short_circuited_constantsexempts never-evaluated operands that are themselves constant from short-circuit findings. Disable these options to report such deliberate constants as well.
After the upgrade, existing findings of the affected rules may appear as removed and newly added in the Dashboard because their locations and message texts changed. If you disabled or enabled individual message keys of FaultDetection-DeadBranches in your configuration, review your configuration against the message keys listed in the rule’s documentation.
The following rules are also affected, as they use FaultDetection-DeadBranches internally:
MisraC-13.7,
MisraC-21.1,
MisraC++-0.1.2,
MisraC++-0.1.9,
MisraC++-0.3.1,
MisraC++2023-0.0.2,
MisraC2012-2.2,
MisraC2012-14.3,
MisraC2012Directive-4.1,
MisraC2019-2.2,
MisraC2019-14.3,
MisraC2019Directive-4.1,
MisraC2023-2.2,
MisraC2023-14.3,
MisraC2023Directive-4.1,
MisraC2025-2.2,
MisraC2025-14.3, and
MisraC2025Directive-4.1.