Last week, I did this: > * lib/stddef.in.h: In C++ mode, include <utility> and either import > 'unreachable' from the std namespace or define it as an inline function.
Unfortunately, that does not work across platforms. On FreeBSD 14, for example, the #include <utility> from within stddef.h (which gets included from <cstddef>) leads to compilation errors (attached). This patch works around the issue, by using a new macro gl_unreachable in code that should be usable in both C and C++. 2025-06-02 Bruno Haible <br...@clisp.org> stddef-h: Fix compilation errors in C++ mode (regression 2025-05-27). * m4/stddef_h.m4 (gl_STDDEF_H): Set and substitute HAVE_C_UNREACHABLE. Don't test for unreachable in <stddef.h> in C++. Set GL_GENERATE_STDDEF_H to true always. * lib/stddef.in.h (gl_unreachable): Renamed from _gl_unreachable. Test HAVE_C_UNREACHABLE. (unreachable): Don't define in C++ mode. Don't define if HAVE_C_UNREACHABLE is 1. * modules/stddef-h (Makefile.am): Substitute HAVE_C_UNREACHABLE. * tests/test-stddef-h.c (test_unreachable_optimization, test_unreachable_noreturn): Don't define in C++ mode. (test_gl_unreachable_optimization, test_gl_unreachable_noreturn): New functions. * tests/test-stddef-h-c++3.cc (test_cxx_unreachable_1): Test gl_unreachable instead of unreachable. * lib/error.in.h (__gl_error_call1): Use gl_unreachable instead of unreachable. diff --git a/lib/error.in.h b/lib/error.in.h index 24a619f4a4..6c512ec8e5 100644 --- a/lib/error.in.h +++ b/lib/error.in.h @@ -39,7 +39,7 @@ /* Get va_list. */ #include <stdarg.h> -/* Get 'unreachable'. */ +/* Get 'gl_unreachable'. */ #include <stddef.h> /* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */ @@ -57,11 +57,11 @@ It evaluates its arguments only once. Test case: Compile copy-file.c with "gcc -Wimplicit-fallthrough". */ #if defined __GNUC__ || defined __clang__ -/* Use 'unreachable' to tell the compiler when the function call does not +/* Use 'gl_unreachable' to tell the compiler when the function call does not return. */ # define __gl_error_call1(function, status, ...) \ ((function) (status, __VA_ARGS__), \ - (status) != 0 ? unreachable () : (void) 0) + (status) != 0 ? gl_unreachable () : (void) 0) /* If STATUS is a not a constant, the function call may or may not return; therefore -Wimplicit-fallthrough will produce a warning. Use a compound statement in order to evaluate STATUS only once. diff --git a/lib/stddef.in.h b/lib/stddef.in.h index 2754e881e7..e8c55ff1cd 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -188,6 +188,17 @@ typedef union #endif /* ISO C 23 ยง 7.21.1 The unreachable macro */ +/* This macro is only usable in C, not in C++. + There is no way to define it as a macro in C++, because that would break code + that does + #include <utility> + ... std::unreachable() ... + Similarly, there is no way to define it as an inline function in C++, because + that would break code that does + #include <utility> + using std::unreachable; + As a workaround, we define a macro gl_unreachable, that is like unreachable, + but is usable in both C and C++. */ /* Code borrowed from verify.h. */ #ifndef _GL_HAS_BUILTIN_UNREACHABLE @@ -203,9 +214,11 @@ typedef union #endif #if _GL_HAS_BUILTIN_UNREACHABLE -# define _gl_unreachable() __builtin_unreachable () +# define gl_unreachable() __builtin_unreachable () #elif 1200 <= _MSC_VER -# define _gl_unreachable() __assume (0) +# define gl_unreachable() __assume (0) +#elif !defined __cplusplus && @HAVE_C_UNREACHABLE@ +# define gl_unreachable() unreachable () #else /* Declare abort(), without including <stdlib.h>. */ extern @@ -218,36 +231,14 @@ void abort (void) _GL_ATTRIBUTE_NOTHROW # endif ; -# define _gl_unreachable() abort () +# define gl_unreachable() abort () #endif -#ifndef __cplusplus +#if !defined __cplusplus && !@HAVE_C_UNREACHABLE@ /* In C, define unreachable as a macro. */ # ifndef unreachable -# define unreachable() _gl_unreachable () -# endif - -#else -/* In C++, define unreachable as an inline function. */ - -/* With some versions of MSVC, the inclusion of <utility> here causes errors - when <cstddef> gets included: - type_traits(1164): error C2065: 'max_align_t': undeclared identifier */ -# if !defined _MSC_VER -extern "C++" { /* needed for Cygwin */ -# include <utility> -} -# endif - -# if defined __cpp_lib_unreachable /* C++23 or newer */ - -using std::unreachable; - -# else - -inline void unreachable () { _gl_unreachable (); } - +# define unreachable() gl_unreachable () # endif #endif diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index bdcb428017..127ec05b60 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -1,5 +1,5 @@ # stddef_h.m4 -# serial 22 +# serial 23 dnl Copyright (C) 2009-2025 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -77,32 +77,13 @@ AC_DEFUN_ONCE([gl_STDDEF_H] ]) if test $gl_cv_c_func_unreachable = no; then GL_GENERATE_STDDEF_H=true + HAVE_C_UNREACHABLE=0 + else + HAVE_C_UNREACHABLE=1 fi - if test "$CXX" != no; then - dnl C++ <utility> has std::unreachable, - dnl see <https://en.cppreference.com/w/cpp/utility/unreachable>, - dnl but we want an unreachable() that is available from <stddef.h>, - dnl like in ISO C 23. - AC_CACHE_CHECK([for unreachable in <stddef.h> in C++], - [gl_cv_cxx_func_unreachable], - [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to - dnl an autoconf bug <https://savannah.gnu.org/support/?110294>. - cat > conftest.cpp <<\EOF -#include <stddef.h> -int main (void) { unreachable (); } -EOF - gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp" - if AC_TRY_EVAL([gl_command]); then - gl_cv_cxx_func_unreachable=yes - else - gl_cv_cxx_func_unreachable=no - fi - rm -fr conftest* - ]) - if test $gl_cv_cxx_func_unreachable = no; then - GL_GENERATE_STDDEF_H=true - fi - fi + AC_SUBST([HAVE_C_UNREACHABLE]) + dnl Provide gl_unreachable() unconditionally. + GL_GENERATE_STDDEF_H=true dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114869 AC_CACHE_CHECK([whether nullptr_t needs <stddef.h>], diff --git a/modules/stddef-h b/modules/stddef-h index 96eeeaf88b..7f4f0c0ef6 100644 --- a/modules/stddef-h +++ b/modules/stddef-h @@ -34,6 +34,7 @@ stddef.h: stddef.in.h $(top_builddir)/config.status -e 's|@''STDDEF_NOT_IDEMPOTENT''@|$(STDDEF_NOT_IDEMPOTENT)|g' \ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \ + -e 's|@''HAVE_C_UNREACHABLE''@|$(HAVE_C_UNREACHABLE)|g' \ $(srcdir)/stddef.in.h > $@-t $(AM_V_at)mv $@-t $@ else diff --git a/tests/test-stddef-h-c++3.cc b/tests/test-stddef-h-c++3.cc index 77242183c8..b3b320b671 100644 --- a/tests/test-stddef-h-c++3.cc +++ b/tests/test-stddef-h-c++3.cc @@ -16,7 +16,7 @@ #include <config.h> -/* Define unreachable. */ +/* Define gl_unreachable. */ #include <stddef.h> /* Define std::unreachable (in C++23 or newer). */ #include <utility> @@ -25,7 +25,7 @@ void test_cxx_unreachable_1 () { if (2 < 1) - unreachable (); + gl_unreachable (); #if defined __cpp_lib_unreachable if (3 < 1) std::unreachable (); diff --git a/tests/test-stddef-h.c b/tests/test-stddef-h.c index f201b411ab..b80df4d445 100644 --- a/tests/test-stddef-h.c +++ b/tests/test-stddef-h.c @@ -69,6 +69,11 @@ static_assert (__alignof__ (struct d) <= __alignof__ (max_align_t)); # endif #endif + +#ifndef __cplusplus + +/* Test 'unreachable'. */ + int test_unreachable_optimization (int x); _Noreturn void test_unreachable_noreturn (void); @@ -93,6 +98,36 @@ test_unreachable_noreturn (void) unreachable (); } +#endif + + +/* Test 'gl_unreachable'. */ + +int test_gl_unreachable_optimization (int x); +_Noreturn void test_gl_unreachable_noreturn (void); + +int +test_gl_unreachable_optimization (int x) +{ + /* Check that the compiler uses 'gl_unreachable' for optimization. + This function, when compiled with optimization, should have code + equivalent to + return x + 3; + Use 'objdump --disassemble test-stddef.o' to verify this. */ + if (x < 4) + gl_unreachable (); + return (x > 1 ? x + 3 : 2 * x + 10); +} + +_Noreturn void +test_gl_unreachable_noreturn (void) +{ + /* Check that the compiler's data-flow analysis recognizes + 'gl_unreachable ()'. This function should not elicit a warning. */ + gl_unreachable (); +} + + #include <limits.h> /* INT_MAX */ /* offsetof promotes to an unsigned integer if and only if sizes do
gmake all-recursive gmake[1]: Entering directory '/home/bruno/testdir-all/build' Making all in gllib gmake[2]: Entering directory '/home/bruno/testdir-all/build/gllib' gmake all-recursive gmake[3]: Entering directory '/home/bruno/testdir-all/build/gllib' gmake[4]: Entering directory '/home/bruno/testdir-all/build/gllib' gmake[4]: Nothing to be done for 'all-am'. gmake[4]: Leaving directory '/home/bruno/testdir-all/build/gllib' gmake[3]: Leaving directory '/home/bruno/testdir-all/build/gllib' gmake[2]: Leaving directory '/home/bruno/testdir-all/build/gllib' Making all in glm4 gmake[2]: Entering directory '/home/bruno/testdir-all/build/glm4' gmake[2]: Nothing to be done for 'all'. gmake[2]: Leaving directory '/home/bruno/testdir-all/build/glm4' Making all in gltests gmake[2]: Entering directory '/home/bruno/testdir-all/build/gltests' ## ---------------------------------------------------- ## ## ------------------- Gnulib tests ------------------- ## ## You can ignore compiler warnings in this directory. ## ## ---------------------------------------------------- ## gmake all-recursive gmake[3]: Entering directory '/home/bruno/testdir-all/build/gltests' Making all in . gmake[4]: Entering directory '/home/bruno/testdir-all/build/gltests' depbase=`echo test-math-h-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-math-h-c++.o -MD -MP -MF $depbase.Tpo -c -o test-math-h-c++.o ../../gltests/test-math-h-c++.cc &&\ mv -f $depbase.Tpo $depbase.Po In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:265: In file included from /usr/include/c++/v1/compare:145: 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:20: /usr/include/c++/v1/cmath:558:5: error: use of undeclared identifier '__promote' __promote<_A1, _A2, _A3> ^ /usr/include/c++/v1/cmath:562:22: error: no template named '__promote' typedef typename __promote<_A1, _A2, _A3>::type __result_type; ^ /usr/include/c++/v1/cmath:566:12: error: call to 'hypot' is ambiguous return std::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); ^~~~~~~~~~ /usr/include/c++/v1/cmath:547:46: note: candidate function inline _LIBCPP_INLINE_VISIBILITY float hypot( float __x, float __y, float __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } ^ /usr/include/c++/v1/cmath:548:46: note: candidate function inline _LIBCPP_INLINE_VISIBILITY double hypot( double __x, double __y, double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } ^ /usr/include/c++/v1/cmath:549:46: note: candidate function inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } ^ /usr/include/c++/v1/cmath:587:17: error: expected unqualified-id return std::isnan(__lcpp_x); ^ /usr/include/math.h:103:2: note: expanded from macro 'isnan' __fp_type_select(x, __inline_isnanf, __inline_isnan, __inline_isnanl) ^ /usr/include/math.h:80:39: note: expanded from macro '__fp_type_select' #define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \ ^ In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:265: In file included from /usr/include/c++/v1/compare:145: 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:20: /usr/include/c++/v1/cmath:607:17: error: expected unqualified-id return std::isinf(__lcpp_x); ^ /usr/include/math.h:101:18: note: expanded from macro 'isinf' #define isinf(x) __fp_type_select(x, __isinff, __isinf, __isinfl) ^ /usr/include/math.h:80:39: note: expanded from macro '__fp_type_select' #define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \ ^ In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:265: In file included from /usr/include/c++/v1/compare:145: 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:20: /usr/include/c++/v1/cmath:646:38: error: no member named '__promote' in namespace 'std' std::__promote<_A1, _A2> >::type ~~~~~^ /usr/include/c++/v1/cmath:646:48: error: '_A1' does not refer to a value std::__promote<_A1, _A2> >::type ^ /usr/include/c++/v1/cmath:643:17: note: declared here template <class _A1, class _A2> ^ /usr/include/c++/v1/cmath:646:58: error: expected unqualified-id std::__promote<_A1, _A2> >::type ^ In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:277: /usr/include/c++/v1/cstdlib:132:9: error: target of using declaration conflicts with declaration already in scope using ::abs _LIBCPP_USING_IF_EXISTS; ^ /usr/include/stdlib.h:90:6: note: target of using declaration int abs(int) __pure2; ^ /usr/include/c++/v1/cmath:353:1: note: conflicting declaration using ::abs _LIBCPP_USING_IF_EXISTS; ^ In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:277: /usr/include/c++/v1/cstdlib:132:9: error: target of using declaration conflicts with declaration already in scope using ::abs _LIBCPP_USING_IF_EXISTS; ^ /usr/include/c++/v1/stdlib.h:113:61: note: target of using declaration _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT { ^ /usr/include/c++/v1/cmath:353:1: note: conflicting declaration using ::abs _LIBCPP_USING_IF_EXISTS; ^ In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:277: /usr/include/c++/v1/cstdlib:132:9: error: target of using declaration conflicts with declaration already in scope using ::abs _LIBCPP_USING_IF_EXISTS; ^ /usr/include/c++/v1/stdlib.h:116:66: note: target of using declaration _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT { ^ /usr/include/c++/v1/cmath:353:1: note: conflicting declaration using ::abs _LIBCPP_USING_IF_EXISTS; ^ In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:277: /usr/include/c++/v1/cstdlib:132:9: error: target of using declaration conflicts with declaration already in scope using ::abs _LIBCPP_USING_IF_EXISTS; ^ /usr/include/c++/v1/stdlib.h:122:62: note: target of using declaration _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT { ^ /usr/include/c++/v1/cmath:353:1: note: conflicting declaration using ::abs _LIBCPP_USING_IF_EXISTS; ^ In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:277: /usr/include/c++/v1/cstdlib:132:9: error: target of using declaration conflicts with declaration already in scope using ::abs _LIBCPP_USING_IF_EXISTS; ^ /usr/include/c++/v1/stdlib.h:126:63: note: target of using declaration _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT { ^ /usr/include/c++/v1/cmath:353:1: note: conflicting declaration using ::abs _LIBCPP_USING_IF_EXISTS; ^ In file included from ../../gltests/test-math-h-c++.cc:22: In file included from ../gllib/math.h:46: In file included from /usr/include/c++/v1/math.h:314: In file included from /usr/include/c++/v1/__type_traits/promote.h:16: In file included from /usr/include/c++/v1/cstddef:43: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:277: /usr/include/c++/v1/cstdlib:132:9: error: target of using declaration conflicts with declaration already in scope using ::abs _LIBCPP_USING_IF_EXISTS; ^ /usr/include/c++/v1/stdlib.h:131:1: note: target of using declaration abs(long double __lcpp_x) _NOEXCEPT { ^ /usr/include/c++/v1/cmath:353:1: note: conflicting declaration using ::abs _LIBCPP_USING_IF_EXISTS; ^ ../../gltests/test-math-h-c++.cc:413:4: warning: "signbit should not be a macro in C++" [-W#warnings] # warning "signbit should not be a macro in C++" ^ 1 warning and 14 errors generated. gmake[4]: *** [Makefile:27245: test-math-h-c++.o] Error 1 depbase=`echo test-string-h-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-string-h-c++.o -MD -MP -MF $depbase.Tpo -c -o test-string-h-c++.o ../../gltests/test-string-h-c++.cc &&\ mv -f $depbase.Tpo $depbase.Po In file included from ../../gltests/test-string-h-c++.cc:22: In file included from ../gllib/string.h:41: In file included from /usr/include/c++/v1/string.h:61: In file included from /usr/include/string.h:46: In file included from ../gllib/strings.h:52: In file included from ../gllib/locale.h:54: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:278: In file included from /usr/include/c++/v1/iosfwd:100: In file included from /usr/include/c++/v1/__mbstate_t.h:29: ../gllib/wchar.h:1145:3: error: use of undeclared identifier 'memset'; did you mean 'wmemset'? memset (ps, 0, _GL_MBSTATE_ZERO_SIZE); ^ /usr/include/wchar.h:176:10: note: 'wmemset' declared here wchar_t *wmemset(wchar_t *, wchar_t, size_t); ^ In file included from ../../gltests/test-string-h-c++.cc:22: In file included from ../gllib/string.h:41: In file included from /usr/include/c++/v1/string.h:61: In file included from /usr/include/string.h:46: In file included from ../gllib/strings.h:52: In file included from ../gllib/locale.h:54: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:278: In file included from /usr/include/c++/v1/iosfwd:100: In file included from /usr/include/c++/v1/__mbstate_t.h:29: ../gllib/wchar.h:1145:11: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'mbstate_t *' (aka '__mbstate_t *') memset (ps, 0, _GL_MBSTATE_ZERO_SIZE); ^~ /usr/include/wchar.h:176:27: note: passing argument to parameter here wchar_t *wmemset(wchar_t *, wchar_t, size_t); ^ 2 errors generated. gmake[4]: *** [Makefile:27245: test-string-h-c++.o] Error 1 depbase=`echo test-string-h-c++2.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-string-h-c++2.o -MD -MP -MF $depbase.Tpo -c -o test-string-h-c++2.o ../../gltests/test-string-h-c++2.cc &&\ mv -f $depbase.Tpo $depbase.Po In file included from ../../gltests/test-string-h-c++2.cc:20: In file included from /usr/include/c++/v1/cstring:63: In file included from ../gllib/string.h:41: In file included from /usr/include/c++/v1/string.h:61: In file included from /usr/include/string.h:46: In file included from ../gllib/strings.h:52: In file included from ../gllib/locale.h:54: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:278: In file included from /usr/include/c++/v1/iosfwd:100: In file included from /usr/include/c++/v1/__mbstate_t.h:29: ../gllib/wchar.h:1145:3: error: use of undeclared identifier 'memset'; did you mean 'wmemset'? memset (ps, 0, _GL_MBSTATE_ZERO_SIZE); ^ /usr/include/wchar.h:176:10: note: 'wmemset' declared here wchar_t *wmemset(wchar_t *, wchar_t, size_t); ^ In file included from ../../gltests/test-string-h-c++2.cc:20: In file included from /usr/include/c++/v1/cstring:63: In file included from ../gllib/string.h:41: In file included from /usr/include/c++/v1/string.h:61: In file included from /usr/include/string.h:46: In file included from ../gllib/strings.h:52: In file included from ../gllib/locale.h:54: In file included from ../gllib/stddef.h:240: In file included from /usr/include/c++/v1/utility:278: In file included from /usr/include/c++/v1/iosfwd:100: In file included from /usr/include/c++/v1/__mbstate_t.h:29: ../gllib/wchar.h:1145:11: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'mbstate_t *' (aka '__mbstate_t *') memset (ps, 0, _GL_MBSTATE_ZERO_SIZE); ^~ /usr/include/wchar.h:176:27: note: passing argument to parameter here wchar_t *wmemset(wchar_t *, wchar_t, size_t); ^ 2 errors generated. gmake[4]: *** [Makefile:27245: test-string-h-c++2.o] Error 1 gmake[4]: Target 'all-am' not remade because of errors. gmake[4]: Leaving directory '/home/bruno/testdir-all/build/gltests' gmake[3]: *** [Makefile:27288: all-recursive] Error 1 gmake[3]: Leaving directory '/home/bruno/testdir-all/build/gltests' gmake[2]: *** [Makefile:18253: all] Error 2 gmake[2]: Leaving directory '/home/bruno/testdir-all/build/gltests' gmake[2]: Entering directory '/home/bruno/testdir-all/build' gmake[2]: Leaving directory '/home/bruno/testdir-all/build' gmake[1]: *** [Makefile:3533: all-recursive] Error 1 gmake[1]: Leaving directory '/home/bruno/testdir-all/build' gmake: *** [Makefile:3460: all] Error 2