[clang] [llvm] [clang-tools-extra] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 31 12:38:07 PST 2024


zeroomega wrote:

> > Hi, I am seeing breakages on some of our audio code on tip of tree Clang and I traced it back to this patch.
> > We uses `-ffast-math` mode for performance reasons but we also uses `-fhonor-infinities`, `-fhonor-nans` and `fno-finite-math-only` to ensure that the behavior of infinity is correct. But the message `error: use of infinity is undefined behavior due to the currently enabled floating-point options [-Werror,-Wnan-infinity-disabled] ` was still produced by the compiler. Is this intended behavior? If not, could you revert, revise and reland the change please?
> > Thanks.
> 
> What is the order you're passing the flags? This may have actually pointed out a difference between what you expected and what actually happens (which is part of the point to these changes): https://godbolt.org/z/x54qTGoMG

Thanks for the tip.
I think it is the ordering issue on our side. The build system actually put 2 `-ffast-math` flags into the command line (we expect 1 but some the buildfile have a bug), The build system placed `-fhonor-infinities, -fhonor-nans` before the 2nd `-ffast-math` flag and this 2nd `--ffast-math` resets those honor flags I assume, and we saw the warning. 

https://github.com/llvm/llvm-project/pull/76873


More information about the cfe-commits mailing list