================ @@ -13861,6 +13897,36 @@ Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType, CheckPPCMMAType(RetValExp->getType(), ReturnLoc); } +/// Diagnose comparison to NAN or INFINITY in fast math modes. +/// The comparison to NaN or INFINITY is always false in +/// fast modes: float evaluation will not result in inf or nan. +void Sema::CheckInfNaNFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, ---------------- AaronBallman wrote:
The basic idea I have is that it's UB to generate a constant infinity or NaN if infinity/NaN is disabled. Instead of performing special logic for float comparisons, I think the logic should live in `Sema::ActOnNumericConstant()` so that we capture any time a float or infinity constant is used. e.g. `inf + 1` should also diagnose. Then the tautological comparison component to this could be implemented by looking for calls to `__builtin_isinf` or `__builtin_isnan` and claim those are tautologically false (as a follow-up patch). WDYT? https://github.com/llvm/llvm-project/pull/76873 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits