eggert@twinsun.com (Paul Eggert) (02/03/90)
The following function should yield 1. But under GCC 1.36 (SPARCstation 1, SunOS 4.0.3c), it yields 0. #include <limits.h> main() { return INT_MIN < 0; } The problem is that INT_MIN yields an unsigned value. This contradicts ANSI C 2.2.4.2, which says that INT_MIN shall ``have the same type as would an expression that is an object of the corresponding type converted according to the integral promotions.'' Here is a fix. *** old/limits.h Mon Sep 25 15:00:53 1989 --- new/limits.h Fri Feb 2 12:40:56 1990 *************** *** 28,34 **** #define USHRT_MAX 65535U /* Minimum and maximum values a `signed int' can hold. */ ! #define INT_MIN -2147483648 #define INT_MAX 2147483647 /* Maximum value an `unsigned int' can hold. (Minimum is 0). */ --- 28,34 ---- #define USHRT_MAX 65535U /* Minimum and maximum values a `signed int' can hold. */ ! #define INT_MIN (-INT_MAX-1) #define INT_MAX 2147483647 /* Maximum value an `unsigned int' can hold. (Minimum is 0). */