From: Bruno Haible Date: Tue, 3 Feb 2026 09:46:27 +0000 (+0100) Subject: isinf: Make more C++ safe. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4ef84e62578dc733482fc945799ce97eb236100;p=thirdparty%2Fgnulib.git isinf: Make more C++ safe. * lib/math.in.h (isinf): In C++ mode, define as a template with three instantiations, instead of as a macro. --- diff --git a/ChangeLog b/ChangeLog index 7d9831f49d..f7874afd1f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2026-02-03 Bruno Haible + + isinf: Make more C++ safe. + * lib/math.in.h (isinf): In C++ mode, define as a template with three + instantiations, instead of as a macro. + 2026-02-02 Bruno Haible isinf: Avoid unnecessary override of isinf(). diff --git a/lib/math.in.h b/lib/math.in.h index 210ac99cf3..357b68e31d 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -2508,11 +2508,18 @@ _GL_WARN_REAL_FLOATING_DECL (isfinite); _GL_EXTERN_C int gl_isinff (float x); _GL_EXTERN_C int gl_isinfd (double x); _GL_EXTERN_C int gl_isinfl (long double x); -# undef isinf -# define isinf(x) \ - (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ - sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ - gl_isinff (x)) +# ifdef __cplusplus +template int isinf (T); +template <> inline int isinf (float x) { return gl_isinff (x); } +template <> inline int isinf (double x) { return gl_isinfd (x); } +template <> inline int isinf (long double x) { return gl_isinfl (x); } +# else +# undef isinf +# define isinf(x) \ + (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ + sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ + gl_isinff (x)) +# endif # endif # if @GNULIB_ISINF@ && defined __cplusplus # if defined isinf || defined GNULIB_NAMESPACE