Skip to content

gh-136006: fix Py_NAN expansion on Solaris systems #136575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Include/pymath.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,24 @@

/* Py_NAN: Value that evaluates to a quiet Not-a-Number (NaN). The sign is
* undefined and normally not relevant, but e.g. fixed for float("nan").
*
* Note: On Solaris, NAN is a function address, hence arithmetic is impossible.
* For that reason, we instead use the built-in call if available or fallback
* to a generic NaN computed from strtod() as a last resort.
*
* See https://github.com/python/cpython/issues/136006 for details.
*/
#if !defined(Py_NAN)
# define Py_NAN ((double)NAN)
# if defined(__sun)
# if _Py__has_builtin(__builtin_nanf)
# define Py_NAN ((double)__builtin_nanf(""))
# else
# include <stdlib.h>
# define Py_NAN (strtod("NAN", NULL))
# endif
# else
# define Py_NAN ((double)NAN)
# endif
#endif

#endif /* Py_PYMATH_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
On Solaris, the :c:macro:`!Py_NAN` macro now expands to a :c:type:`!double`
instead of a function address. Patch by Bénédikt Tran.
Loading