On Fri, Feb 28, 2020 at 04:11:15PM +0100, Tobias Burnus wrote: > On 2/28/20 3:53 PM, Segher Boessenkool wrote: > > It happens with -O2 already. The frontend generates a MIN_EXPR (or > > MAX_EXPR) for this, which is undefined for NaNs already. I think the > > testcase is just invalid? > > Ups, that shouldn't happen. It does seem to work here > (x86-64-gnu-linux), however, running various compile flags including -O3 > and -O2. > > Regarding MIN and MAX: I think the IEEE 754 decided at some point > decided that MAX(x, NaN) = x (IEEE 754:2008 alias ISO 60559:2011, if I > recall correctly). I think one has to check what exactly the test case > does and what is guaranteed where. I also do not know whether a more > recent IEEE 754 (754:2019) has changed something again.
IEEE-754-2008 does not have MAX(), and it defines quiet and signaling NaNs. It does have maxNum(): maxNum(x, y) is the canonicalized number y if x < y, x if y < x, the canonicalized number if one operand is a number and the other a quiet NaN. Otherwise it is either x or y, canonicalized (this means results might differ among implementations). When either x or y is a signalingNaN, then the result is according to 6.2. -- Steve