25-09-2026, 05:43 PM
The short unhelpful answer is that this code is not covered by MISRA C++:2008, as fpclassify didn't come in until C++:2011.
The more considered answer is that the use of fpclassify is technically legal, but certainly wasn't considered when we wrote the rule, and ought to be regarded as malicious compliance and highlighted during code review - as should any attempt to bypass a rule in a way that obfuscates the code's meaning.
It would be better to deviate an obvious comparison with zero, if there is a good reason why such a test is appropriate, e.g. identifying a floating point parameter that if not required and which has been explicitly set to zero. See the MISRA compliance document.
The more considered answer is that the use of fpclassify is technically legal, but certainly wasn't considered when we wrote the rule, and ought to be regarded as malicious compliance and highlighted during code review - as should any attempt to bypass a rule in a way that obfuscates the code's meaning.
It would be better to deviate an obvious comparison with zero, if there is a good reason why such a test is appropriate, e.g. identifying a floating point parameter that if not required and which has been explicitly set to zero. See the MISRA compliance document.
Posted by and on behalf of
the MISRA C++ Working Group
the MISRA C++ Working Group

