[clang] [C23] Support the SNAN macros in <float.h> (PR #162858)

Joshua Cranmer via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 10 11:24:32 PDT 2025


jcranmer-intel wrote:

> I have a question about interpreting the standard. The standard says each of these macros "is defined if and only if the respective type contains signaling NaNs." Given that by default LLVM IR gives the compiler permission to treat all NaNs as if they were quiet NaNs, should we really be defining these macros in the default mode?
> 
> My understanding is that these built-ins will indeed produce a signaling NaN value, but the quiet/signaling behavior may not be respected by the optimizer.

The way I interpret the standard, it discusses whether or not the *format of the type* supports sNaNs, not whether or not the current floating-point model has full sNaN operational semantics. Since the IEEE 754 types support sNaNs, then they should have sNaN support enabled for them.

Whether or not the sNaN types are actually usable is actually envisioned by the standard--there's actually a `FE_SNANS_ALWAYS_SIGNAL` macro in Annex F for indicating whether or not sNaNs are fully following IEEE 754 operational semantics.

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


More information about the cfe-commits mailing list