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.
This commit is contained in:
Rich Felker 2018-03-10 20:45:49 -05:00
parent eb5ae94016
commit 919ad8d5fb
1 changed files with 4 additions and 4 deletions

View File

@ -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;