jcranmer-intel wrote: Some thoughts of my own:
The decision being discussed here has two main repercussions: * An attempt to use `INFINITY` gets a symbol-not-found error message, or it gets whatever warning/error message we attach to `__builtin_inf()` in `-ffinite-math-only` mode. * Code that uses `#ifndef INFINITY` may or may not trigger. In the first case, I think you get a better error message with the `__builtin_inf()` usecase directly. For the second case, well, the main question is "why would someone use this in the first place." From a search on sourcegraph for existing uses of check for the `INFINITY` macro, by far the single most common case was to immediately define their own version of `INFINITY` by constructing an infinite value, usually by intentional overflow. Most programmers, if they have any understanding of floating-point, would understand floating point only in terms of IEEE 754 types, which have an infinity; the existence of floating-point formats that lack infinities is going to be new to them, much less the ability to test such systems. So the lack of an `INFINITY` macro is likely to be seen less as "this compiler doesn't support infinities" and more likely to be seen as "this compiler doesn't support a new enough standard," hence the workarounds to construct an appropriate infinite value. (Many of the comments actually explicitly state that they are trying to construct an infinity!) Code that attempts to intentionally use infinity in a `-ffinite-math-only` mode is going to break. The choice to me is giving them something where we will immediately complain that their combination of command-line flags and code is likely to do the wrong thing, or giving them something that--in practice--amounts to silently breaking their code, where we could have obviously told them their code was broken. If the user is explicitly savvy about the existence of fast-math, they already have the opportunity to protect themselves from users who blindly apply `-ffast-math`, be it the `__FINITE_MATH_ONLY` macro checks or pragmas to re-enable it. Not defining `INFINITY` for their benefit doesn't give them a lot more control, while reducing our ability to help users who may have blundered themselves into a nonsense configuration. 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. https://github.com/llvm/llvm-project/pull/96659 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits