21-09-2026, 08:37 AM
Hi,
We have seen a creative way to work around MISRA Rule 6-2-2:
Would the last 2 examples be compliant with the rule?
We argue that this is an indirect test for equality and thus non-compliant.
We have seen a creative way to work around MISRA Rule 6-2-2:
Code:
float x = ...;
float y = ...;
if (x == 0.F) // non-compliant
if (x == y) // non-compliant
if (std::fpclassify(x) == FP_ZERO) // compliant?
if (std::fpclassify(x - y) == FP_ZERO) // compliant?Would the last 2 examples be compliant with the rule?
We argue that this is an indirect test for equality and thus non-compliant.

