[clang] [C23] Add INFINITY and NAN macros to <float.h> (PR #96659)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 27 12:23:59 PDT 2024
AaronBallman wrote:
> In short: IMHO, `INFINITY` should expand to something that bops the user (i.e., warn/error by default) and says "you're doing something wrong" in finite-math-only mode.
@jcranmer-intel and I had a really nice offline discussion on this topic and I've come around to his view. I was thinking that the fact we don't currently diagnose use of `__builtin_inf()` in `-ffinite-math-only` mode was because it produced an actual infinity still, but after our discussion, I now agree that it (and `__builtin_nan()`) should diagnose if used when infinities (or NANs) are disabled. This also nicely handles the case with pragmas changing the floating-point mode to be different from what was set on the command line.
So let's split this PR into two parts: 1) I'll update this PR to always define `INFINITY` and `NAN` in `<float.h>`, 2) I'll introduce the warning diagnostic in a follow-up PR.
https://github.com/llvm/llvm-project/pull/96659
More information about the cfe-commits
mailing list