From 919ad8d5fbb1caa18c3719304ffeeb0e0dde1bb5 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 10 Mar 2018 20:45:49 -0500 Subject: [PATCH] explicitly use signed keyword to define intNN_t and derivative types standing alone, both the signed and int keywords identify the same type, a (signed) int. however the C language has an exception where, when the lone keyword int is used to declare a bitfield, it's implementation-defined whether the bitfield is signed or unsigned. C11 footnote 125 extends this implementation-definedness to typedefs, and DR#315 extends it to other integer types (for which support with bitfields is implementation-defined). while reasonable ABIs (all the ones we support) define bitfields as signed by default, GCC and compatible compilers offer an option -funsigned-bitfields to change the default. while any signed types defined without explicit use of the signed keyword are affected, the stdint.h types, especially intNN_t, have a natural use in bitfields. ensure that bitfields defined with these types always have the correct signedness regardless of compiler & flags used. see also GCC PR 83294. --- include/alltypes.h.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/alltypes.h.in b/include/alltypes.h.in index 6a9c105f..622ca01d 100644 --- a/include/alltypes.h.in +++ b/include/alltypes.h.in @@ -7,10 +7,10 @@ TYPEDEF _Addr regoff_t; TYPEDEF _Reg register_t; TYPEDEF signed char int8_t; -TYPEDEF short int16_t; -TYPEDEF int int32_t; -TYPEDEF _Int64 int64_t; -TYPEDEF _Int64 intmax_t; +TYPEDEF signed short int16_t; +TYPEDEF signed int int32_t; +TYPEDEF signed _Int64 int64_t; +TYPEDEF signed _Int64 intmax_t; TYPEDEF unsigned char uint8_t; TYPEDEF unsigned short uint16_t; TYPEDEF unsigned int uint32_t;