1.5.2. Migration to 7.12.4

1.5.2.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, sizeof comparisons, or conditions in template instances) are now reported as well.

  • Findings are now reported at the constant (sub)expression itself or at the short-circuiting operator decided 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 reported as well; 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_assert declarations, case labels, array bounds, bit-field widths, enumerator initializations, non-type template arguments, initializers of constexpr variables, and noexcept specifications) are no longer reported.

  • Two message keys were added and are enabled by default: dead_param_dependent_var_true_branch_type_limits and dead_param_dependent_var_false_branch_type_limits. They report conditions on variables whose value depends on a parameter and that are constant due to the limited range of a data type, complementing the existing dead_param_dependent_var_true_branch and dead_param_dependent_var_false_branch message keys.

  • Two options were added and are enabled by default: ignore_literal_subexpressions exempts literal operands of short-circuiting operators inside conditions, as in assert(false && "message"), from subexpression findings, and ignore_short_circuited_constants exempts 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 show up 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:

  • AutosarC++17_03-M0.1.2,

  • AutosarC++17_03-M0.1.9,

  • AutosarC++17_03-M0.3.1,

  • AutosarC++17_10-M0.1.2,

  • AutosarC++17_10-M0.1.9,

  • AutosarC++17_10-M0.3.1,

  • AutosarC++18_03-M0.1.2,

  • AutosarC++18_03-M0.1.9,

  • AutosarC++18_03-M0.3.1,

  • AutosarC++18_10-M0.1.2,

  • AutosarC++18_10-M0.1.9,

  • AutosarC++18_10-M0.3.1,

  • AutosarC++19_03-M0.1.2,

  • AutosarC++19_03-M0.1.9,

  • AutosarC++19_03-M0.3.1,

  • CertC-MSC12,

  • CWE-561,

  • 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.