On AIX in a testdir of all modules, using
'./configure --disable-year2038 && make' I see the following failure:

    depbase=`echo test-nullptr-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
    g++ -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../gllib 
-I./../gllib -D_THREAD_SAFE  -Wno-error -g -O2 -MT test-nullptr-c++.o -MD -MP 
-MF $depbase.Tpo -c -o test-nullptr-c++.o test-nullptr-c++.cc &&\
    mv -f $depbase.Tpo $depbase.Po
    In file included from ../gllib/pthread.h:62,
                     from 
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/powerpc-ibm-aix7.3.0.0/bits/gthr-posix.h:35,
                     from 
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/powerpc-ibm-aix7.3.0.0/bits/gthr-default.h:30,
                     from 
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/powerpc-ibm-aix7.3.0.0/bits/gthr.h:148,
                     from 
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/ext/atomicity.h:35,
                     from 
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/bits/ios_base.h:39,
                     from 
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/ios:42,
                     from 
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/ostream:38,
                     from 
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/iostream:39,
                     from test-nullptr-c++.cc:25:
    
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/bits/basic_string.h:
 In function 'int std::__cxx11::stoi(const string&, std::size_t*, int)':
    
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/10/include/c++/bits/basic_string.h:6557:47:
 error: 'rpl_strtol' is not a member of 'std'; did you mean 'rpl_strtol'?
     6557 |   { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi", 
__str.c_str(),
          |
    [...]

Trimmed the rest of the errors for strtoll, strtoul, etc.

This is the same as Bruno found on Solaris 11 OmniOS previously [1]. The
same fix works in this case.

Pushed the attached patch to fix it.

[1] https://lists.gnu.org/archive/html/bug-gnulib/2024-07/msg00129.html

>From 79fa09434c01cae7ee72bc1534257296818e0143 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 12 Apr 2025 13:24:31 -0700
Subject: [PATCH] stdlib: Avoid syntax errors in libstdc++ header files on AIX.

* lib/stdlib.in.h: Include <string> before strtol, strtoll, strtoul, or
strtoull gets defined as a macro.
---
 ChangeLog       | 4 ++++
 lib/stdlib.in.h | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0733b2b95a..33cae49b8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2025-04-12  Collin Funk  <collin.fu...@gmail.com>
 
+	stdlib: Avoid syntax errors in libstdc++ header files on AIX.
+	* lib/stdlib.in.h: Include <string> before strtol, strtoll, strtoul, or
+	strtoull gets defined as a macro.
+
 	aligned-malloc tests: Avoid redefining macros on AIX.
 	* tests/test-aligned-malloc.c (ALIGNMENT): Undefine any definition from
 	system headers.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 2077a63fc6..dbe8ebc850 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -120,14 +120,14 @@ struct random_data
 # include <unistd.h>
 #endif
 
-#if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__ && !defined __clang__ && defined __sun
+#if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__ && !defined __clang__ && (defined __sun || defined _AIX)
 /* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro
    below, this may cause compilation errors later in the libstdc++ header files
    (that are part of GCC), such as:
      error: 'rpl_strtol' is not a member of 'std'
    To avoid this, include the relevant header files here, before these symbols
-   get defined as macros.  But do so only on Solaris 11 (where it is needed),
-   not on mingw (where it would cause other compilation errors).  */
+   get defined as macros.  But do so only on Solaris 11 and AIX (where it is
+   needed), not on mingw (where it would cause other compilation errors).  */
 # include <string>
 #endif
 
-- 
2.49.0

Reply via email to