AaronBallman wrote:

> I'm not sure about tying this to `__FINITE_MATH_ONLY__`; -ffinite-math-only 
> doesn't mean infinity doesn't exist, it just means you're promising that you 
> won't use floating-point arithmetic/comparison ops on infinity. Which is 
> weird, but that's fast-math. Also, other implementations don't do this.

The requirement that you only define the macro if inf/nan "is supported" is new 
in C23, so I don't expect anyone to have implemented this yet. As for 
`__FINITE_MATH_ONLY__`, our 
[documentation](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-ffinite-math-only)
 mention "results" and that implies (at least to me) that an expression cannot 
form an infinity to begin with, so the act of trying to expand `INFINITY` is 
nonsensical in that case, right?

> In C99, INFINITY and NAN are macros in math.h, not float.h. Is it correct to 
> check __STDC_VERSION__ >= 199901L?

In C99, C11, and C17 `INFINITY` and `NAN` are only defined in `math.h`. In C23, 
the definition is now in both `math.h` and `float.h`. The `float.h` requirement 
comes from 5.2.5.3.3 `Characteristics of floating types <float.h>` (p29 and 
p3), and the `math.h` requirement comes from 7.12 `Mathematics <math.h>` (p7 
and p9). I'm not 100% certain of why they're in both, but I think it's for 
freestanding conformance reasons (math.h isn't [always] in freestanding but 
float.h [always] is).

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

Reply via email to