int8_t is currently defined as char in Solaris <sys/int_types.h>
/*
* Basic / Extended integer types
*
* The following defines the basic fixed-size integer types.
*
* Implementations are free to typedef them to Standard C integer types or
* extensions that they support. If an implementation does not support one
* of the particular integer data types below, then it should not define the
* typedefs and macros corresponding to that data type. Note that int8_t
* is not defined in -Xs mode on ISAs for which the ABI specifies "char"
* as an unsigned entity because there is no way to define an eight bit
* signed integral.
*/
#if defined(_CHAR_IS_SIGNED)
typedef char int8_t;
#else
#if defined(__STDC__)
typedef signed char int8_t;
#endif
#endif
and _CHAR_IS_SIGNED defined as 1 in <sys/isa_defs.h>. As has long been
known, this violates C99, 7.18.1.1, Exact-width integer types.
While this works in general nonetheless, it creates constant trouble for
C++ code as can be seen in PRs libstdc++/113450 and recently
libstdc++/123176, but also in LLVM.
While Oracle Solaris engineering is amenable to changing int8_t to
signed char, this will take time. However, it proved easy to do so now
using fixincludes.
This works for a GCC bootstrap just fine with one exception: as
documented in PR d/123509, libdruntime has its own definition of int8_t
which is now inconsistent with GCC's. This leads to some gdc.test and
libphobos testsuite failures, which can easily be fixed with the patch
attached to that PR. I wouldn't consider this a showstopper for GCC 16
if that patch wouldn't make it to the release.
However, the failures point to another problem: with this change, the
mangling of
void func(int8_t);
changes in C++, creating an ABI break. Fortunately, this isn't seen in
libstdc++, so the impact should be reasonable compared to the constant
trouble the current definition causes for C++.
Besides, clang already uses
#define __INT8_TYPE__ signed char
apparently without problems.
Bootstrapped on i386-pc-solaris2.11, amd64-pc-solaris2.11,
sparc-sun-solaris2.11, and sparcv9-sun-solaris2.11 with only the D
failure described above.
I've also run 1-stage and bootstrap builds of LLVM main using a patched
GCC 16 as bootstrap compiler on amd64-pc-solaris2.11 and
sparcv9-sun-solaris2.11 without regressions.
So unless additional concerns come up, I'll commit this patch in a
couple of days.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2026-01-07 Rainer Orth <[email protected]>
fixincludes:
PR libstdc++/113450
PR libstdc++/123176
* inclhack.def (solaris_int8_t): New fix.
* fixincl.x: Regenerate.
gcc:
PR libstdc++/113450
PR libstdc++/123176
* config/sol2.h (INT8_TYPE): Change to signed char.
(INT_LEAST8_TYPE): Likewise.
(INT_FAST8_TYPE): Likewise.
# HG changeset patch
# Parent e259dda145666d100b99954e352bec315fb7ef8f
Change int8_t to signed char on Solaris [PR113450]
diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
- * It has been AutoGen-ed January 6, 2026 at 04:43:53 PM by AutoGen 5.18.12
+ * It has been AutoGen-ed January 7, 2026 at 12:44:48 PM by AutoGen 5.18.12
* From the definitions inclhack.def
* and the template file fixincl
*/
-/* DO NOT MERGE THIS FILE, EITHER Tue Jan 6 16:43:53 CET 2026
+/* DO NOT MERGE THIS FILE, EITHER Wed Jan 7 12:44:48 CET 2026
*
* You must regenerate it. Use the ./genfixes script.
*
@@ -15,7 +15,7 @@
* certain ANSI-incompatible system header files which are fixed to work
* correctly with ANSI C and placed in a directory that GNU C will search.
*
- * This file contains 250 fixup descriptions.
+ * This file contains 251 fixup descriptions.
*
* See README for more information.
*
@@ -7871,6 +7871,43 @@ static const char* apzSolaris_Int_Limits
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
+ * Description of Solaris_Int8_T fix
+ */
+tSCC zSolaris_Int8_TName[] =
+ "solaris_int8_t";
+
+/*
+ * File name selection pattern
+ */
+tSCC zSolaris_Int8_TList[] =
+ "sys/int_types.h\0";
+/*
+ * Machine/OS name selection pattern
+ */
+tSCC* apzSolaris_Int8_TMachs[] = {
+ "*-*-solaris2*",
+ (const char*)NULL };
+
+/*
+ * content selection pattern - do fix if pattern found
+ */
+tSCC zSolaris_Int8_TSelect0[] =
+ "^[ \t]*typedef[ \t]*char[ \t]*int(|_fast|_least)8_t.*";
+
+#define SOLARIS_INT8_T_TEST_CT 1
+static tTestDesc aSolaris_Int8_TTests[] = {
+ { TT_EGREP, zSolaris_Int8_TSelect0, (regex_t*)NULL }, };
+
+/*
+ * Fix Command Arguments for Solaris_Int8_T
+ */
+static const char* apzSolaris_Int8_TPatch[] = {
+ "format",
+ "typedef signed char int%18_t;",
+ (char*)NULL };
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
* Description of Solaris_Math_12 fix
*/
tSCC zSolaris_Math_12Name[] =
@@ -10235,9 +10272,9 @@ static const char* apzX11_SprintfPatch[]
*
* List of all fixes
*/
-#define REGEX_COUNT 289
+#define REGEX_COUNT 290
#define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT 250
+#define FIX_COUNT 251
/*
* Enumerate the fixes
@@ -10434,6 +10471,7 @@ typedef enum {
SOLARIS_INT_CONST_FIXIDX,
SOLARIS_INT_LIMITS_1_FIXIDX,
SOLARIS_INT_LIMITS_3_FIXIDX,
+ SOLARIS_INT8_T_FIXIDX,
SOLARIS_MATH_12_FIXIDX,
SOLARIS_POW_INT_OVERLOAD_FIXIDX,
STATSSWTCH_FIXIDX,
@@ -11451,6 +11489,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
SOLARIS_INT_LIMITS_3_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aSolaris_Int_Limits_3Tests, apzSolaris_Int_Limits_3Patch, 0 },
+ { zSolaris_Int8_TName, zSolaris_Int8_TList,
+ apzSolaris_Int8_TMachs,
+ SOLARIS_INT8_T_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aSolaris_Int8_TTests, apzSolaris_Int8_TPatch, 0 },
+
{ zSolaris_Math_12Name, zSolaris_Math_12List,
apzSolaris_Math_12Machs,
SOLARIS_MATH_12_TEST_CT, FD_MACH_ONLY,
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -3931,6 +3931,23 @@ fix = {
};
/*
+ * Solaris <sys/int_types.h> defines int8_t as char which violates C99.
+ * Same for int_fast8_t and int_least8_t.
+ */
+fix = {
+ hackname = solaris_int8_t;
+ files = sys/int_types.h;
+ mach = '*-*-solaris2*';
+ c_fix = format;
+ c_fix_arg = "typedef signed char int%18_t;";
+ select = "^[ \t]*typedef[ \t]*char[ \t]*int(|_fast|_least)8_t.*";
+ test_text =
+ "typedef char int8_t;\n"
+ "typedef char int_fast8_t;\n"
+ "typedef char int_least8_t;";
+};
+
+/*
* Some versions of Solaris 10+ <math.h> #undef libstdc++-internal macros.
*/
fix = {
diff --git a/fixincludes/tests/base/sys/int_types.h b/fixincludes/tests/base/sys/int_types.h
new file mode 100644
--- /dev/null
+++ b/fixincludes/tests/base/sys/int_types.h
@@ -0,0 +1,16 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/sys/int_types.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( SOLARIS_INT8_T_CHECK )
+typedef signed char int8_t;
+typedef signed char int_fast8_t;
+typedef signed char int_least8_t;
+#endif /* SOLARIS_INT8_T_CHECK */
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -49,9 +49,11 @@ along with GCC; see the file COPYING3.
#define SIG_ATOMIC_TYPE "int"
-/* ??? This definition of int8_t follows the system header but does
- not conform to C99. Likewise int_fast8_t, int_least8_t. */
-#define INT8_TYPE "char"
+/* <sys/int_types.h> uses char (which is signed) to define int8_t, which does
+ not conform to C99, 7.18.1.1 Exact-width integer types. Likewise
+ int_fast8_t, int_least8_t. Until this is fixed, it's handled by
+ fixincludes. */
+#define INT8_TYPE "signed char"
#define INT16_TYPE "short int"
#define INT32_TYPE "int"
#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
@@ -60,7 +62,7 @@ along with GCC; see the file COPYING3.
#define UINT32_TYPE "unsigned int"
#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
-#define INT_LEAST8_TYPE "char"
+#define INT_LEAST8_TYPE "signed char"
#define INT_LEAST16_TYPE "short int"
#define INT_LEAST32_TYPE "int"
#define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
@@ -69,7 +71,7 @@ along with GCC; see the file COPYING3.
#define UINT_LEAST32_TYPE "unsigned int"
#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
-#define INT_FAST8_TYPE "char"
+#define INT_FAST8_TYPE "signed char"
#define INT_FAST16_TYPE "int"
#define INT_FAST32_TYPE "int"
#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")