https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97965
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> --- See also PR88683 and PR88173. I notice that the match.pd REAL_CST patterns starting around line 4045 only look at the RHS of the comparison, so that nan > inf is handled very differently from inf < nan. And tree_swap_operands_p doesn't swap them around to make it work properly. #define inf __builtin_huge_val() #define nan __builtin_nan("") constexpr bool b1 = inf > nan; constexpr bool b2 = nan < inf;