den-run-ai / msinttypes

Automatically exported from code.google.com/p/msinttypes
0 stars 0 forks source link

INTn_MIN, INTn_MAX violate C99 specification #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
According to ISO/IEC 9899:TC3 7.18.2.2,

"Each instance of [INTn_MIN and INTn_MAX] shall be replaced by a constant 
expansion suitable for use in #if preprocessor directives, and this expression 
shall have the same type as would an expression that is an object of the 
corresponding type converted according to the integer promotions"

The INTn_MAX macros always violated the second requirement, and r19 means that 
the INTn_MIN macros now violate both requirements.

The recommended solution would be to define the INTn_MIN / INTn_MAX macros as 
follows:

#define INT8_MIN     (_I8_MIN + 0)
#define INT8_MAX     (_I8_MAX + 0)
#define INT16_MIN    (_I16_MIN + 0)
#define INT16_MAX    (_I16_MAX + 0)
#define INT32_MIN    (_I32_MIN + 0)
#define INT32_MAX    (_I32_MAX + 0)
#define INT64_MIN    (_I64_MIN + 0)
#define INT64_MAX    (_I64_MAX + 0)
#define UINT8_MAX    (_UI8_MAX + 0)
#define UINT16_MAX   (_UI16_MAX + 0)
#define UINT32_MAX   (_UI32_MAX + 0)
#define UINT64_MAX   (_UI64_MAX + 0)

Original issue reported on code.google.com by cj...@cam.ac.uk on 5 Aug 2010 at 6:28