[clang] [C23] Add INFINITY and NAN macros to <float.h> (PR #96659)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 10:40:20 PDT 2024


efriedma-quic wrote:

> 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?

It's undefined behavior at runtime.

I don't think we need to worry too much about what the C standard says here; the language around floating-point types that don't have infinity was written in the old days before everyone settled on using IEEE math.  And I think the warning we currently produce is probably more helpful in practice than "INFINITY not defined".

----

What I was getting at with the standard version thing is that in standard versions before C23, I don't think NAN is a reserved identifier if you don't include math.h.  So it's forbidden for float.h to define it.

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


More information about the cfe-commits mailing list