Building a testdir of all of Gnulib on FreeBSD 13.2, I see a compilation
error:

depbase=`echo test-nullptr-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; c++ 
-ferror-limit=0 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests 
-I..   -DGNULIB_STRICT_CHECKING=1  -DIN_GNULIB_TESTS=1  -I. -I../../gltests  
-I.. -I../../gltests/..  -I../gllib -I../../gltests/../gllib 
-I/home/bruno/include -I/usr/local/include -Wall -D_THREAD_SAFE  -Wno-error -g 
-O2 -MT test-nullptr-c++.o -MD -MP -MF $depbase.Tpo -c -o test-nullptr-c++.o 
../../gltests/test-nullptr-c++.cc && mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-nullptr-c++.cc:25:
In file included from /usr/include/c++/v1/iostream:37:
In file included from /usr/include/c++/v1/ios:214:
In file included from /usr/include/c++/v1/__locale:18:
In file included from /usr/include/c++/v1/memory:808:
In file included from /usr/include/c++/v1/__functional_base:26:
In file included from /usr/include/c++/v1/utility:236:
In file included from /usr/include/c++/v1/compare:144:
In file included from 
/usr/include/c++/v1/__compare/compare_partial_order_fallback.h:13:
In file included from /usr/include/c++/v1/__compare/partial_order.h:14:
In file included from /usr/include/c++/v1/__compare/weak_order.h:14:
In file included from /usr/include/c++/v1/__compare/strong_order.h:18:
In file included from /usr/include/c++/v1/cmath:308:
../gllib/math.h:3144:43: error: 'isnan' is missing exception specification 
'noexcept'
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool)
                                          ^
/usr/include/c++/v1/math.h:554:1: note: previous declaration is here
isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
^
In file included from ../../gltests/test-nullptr-c++.cc:25:
In file included from /usr/include/c++/v1/iostream:37:
In file included from /usr/include/c++/v1/ios:214:
In file included from /usr/include/c++/v1/__locale:18:
In file included from /usr/include/c++/v1/memory:808:
In file included from /usr/include/c++/v1/__functional_base:26:
In file included from /usr/include/c++/v1/utility:236:
In file included from /usr/include/c++/v1/compare:144:
In file included from 
/usr/include/c++/v1/__compare/compare_partial_order_fallback.h:13:
In file included from /usr/include/c++/v1/__compare/partial_order.h:14:
In file included from /usr/include/c++/v1/__compare/weak_order.h:14:
In file included from /usr/include/c++/v1/__compare/strong_order.h:18:
In file included from /usr/include/c++/v1/cmath:308:
../gllib/math.h:3144:43: error: 'isnan' is missing exception specification 
'noexcept'
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool)
                                          ^
/usr/include/c++/v1/math.h:562:1: note: previous declaration is here
isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
^
2 errors generated.

Strangely, there is no compilation error in test-math-c++.cc nor
test-math-c++2.cc, only in test-nullptr-c++.cc.

This patch fixes it.


2023-04-14  Bruno Haible  <br...@clisp.org>

        isnan: Fix compilation error in C++ mode on FreeBSD 13.2.
        * lib/math.in.h (isnan): On FreeBSD 13.2 or newer, don't declare isnan
        through _GL_MATH_CXX_REAL_FLOATING_DECL_2.

diff --git a/lib/math.in.h b/lib/math.in.h
index 1af4d54d2d..f841a1356e 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -2633,6 +2633,11 @@ _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool)
 #    define isnan rpl_isnan
 #    define GNULIB_NAMESPACE_LACKS_ISNAN 1
+#   elif (defined __FreeBSD__ && __clang_major__ >= 14)
+  /* Neither of the two possible _GL_MATH_CXX_REAL_FLOATING_DECL_2 invocations
+     works.  Inline functions are already present in 
/usr/include/c++/v1/math.h,
+     which comes from LLVM.  */
+#    define GNULIB_NAMESPACE_LACKS_ISNAN 1
 #   else
 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool)
 #   endif




Reply via email to