stdint.h: use correct type for INT64_MAX (#11647)

int64_t is signed. Although it does not make a difference by itself, because
INT64_MAX is still a valid number for uint64_t (UL), the later INT64_MIN
declaration depends on INT64_MAX, and therefore got implicitly casted to
unsigned type.

This fixes the following program on a x86_64 system:

	#include <stdint.h>

	int main() {
		int64_t test = 5;
		if (test < INT64_MIN)
			return 1;
		return 0;
	}

This is a regression since commit 1d13a609 ("stdint.h: define [U]INT64[MAX|MIN]
with [U]L on x86_64").

Signed-off-by: Jerome Duval <jerome.duval@gmail.com>
This commit is contained in:
Timothy Gu 2014-12-19 15:16:47 -08:00 committed by Jerome Duval
parent 0305947d0a
commit d1dc9cf655
1 changed files with 2 additions and 2 deletions

View File

@ -70,10 +70,10 @@ typedef uint64_t uintmax_t;
#define UINT32_MAX (4294967295U)
#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ > 4
#define INT64_MAX (9223372036854775807UL)
#define INT64_MAX (9223372036854775807L)
#define UINT64_MAX (18446744073709551615UL)
#else
#define INT64_MAX (9223372036854775807ULL)
#define INT64_MAX (9223372036854775807LL)
#define UINT64_MAX (18446744073709551615ULL)
#endif
#define INT64_MIN (-INT64_MAX-1)