[PATCH] fold-const: Don't consider NaN non-negative [PR97965]
Fri Nov 27 20:39:12 GMT 2020
On Thu, 26 Nov 2020, Roger Sayle wrote:
> NaNs have a sign-bit, so copyexpr (and negate and ABS_EXPR) are
> well-defined, and it's reasonable for nonnegative_p to reflect this.
> IMHO, the true bug is that we can't fold away (any) comparisons against
> NaN when flag_trapping_math, irrespective of qNaN, -qNaN, sNaN or -sNaN.
I think the comment documenting the semantics of any function mentioning
"nonnegative" needs to say explicitly which of at least three possible
things it means, and then callers should be checked to see if that matches
the semantics they want.
1. !(argument < 0)
2. argument >= 0
Joseph S. Myers
More information about the Gcc-patches