[PATCH] D143074: [LangRef] improve documentation of SNaN in the default FP environment

James Y Knight via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 4 18:19:25 PST 2023


jyknight added a comment.

> C standard library's semantics, which state that pow(1.0, NaN) = 1.0, for any NaN

That's not the case.

In C17, the behavior of signaling NaNs is not defined at all, "This specification does not define the behavior of signaling NaNs. It generally uses the term NaN to denote quiet NaNs" (section F.2.1). On the other hand, C2x draft <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3088.pdf> "recommends" the behavior I describe, and requires it if `FE_SNANS_ALWAYS_SIGNAL` is defined (section F.2.1 paragraphs 6-8).

The glibc math routines have implemented that recommended practice since 2017, for glibc 2.25, and its fenv.h header sets `FE_SNANS_ALWAYS_SIGNAL` if the compiler defines `__SUPPORT_SNAN__`, which GCC sets when `-fsignaling-nans` is passed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143074/new/

https://reviews.llvm.org/D143074



More information about the llvm-commits mailing list