The vulnerability as described in ISO/IEC 24772-1:2024 6.4 applies to C++.
The C++ standard assumes IEC 60559 if std::numeric_limits\<T>::is_iec559 is true for the types in use. In the absence of this, C++ makes few guarantees about the behaviour of floating point numbers. In particular - std::less is not a total order, and - std::equal is not equivalent to substitutability since NaNs compare unequal to themselves but neither less nor greater, and negative zero compares equal to positive zero.
Sorting floating point numbers with the built-in operators violates the preconditions of sorting predicates in the presence of NaN values and can raise floating point errors. The default sorting predicate std::less is suspect to this precondition violation, resulting in undefined behavior [EWF] when sorting a range of floating point values that contain NaNs. This situation can be detected when the return type of operator<=> for a floating point type is std::partial_ordering.
To avoid the vulnerability or mitigate its ill effects, C++ software developers can:
Apply the avoidance mechanisms of ISO/IEC 24772-1 6.4.5
Verify compliance to ISO/IEC/IEEE 60559:2011 at compile time through std::numeric_limits<T>::is_iec559. Other numeric characteristics such as min(), max(), existence of NaNs, has_denorm, and infinities can be determined in this class template.
Be aware that the default comparisons in the standard library can produce wrong results when used on floating point numbers.
Check the ordering properties of the floating-point types at compile time to prevent erroneous ordering operations.