eggert@twinsun.com (Paul Eggert) (02/03/90)
The following contrived program should yield exit status 1. #include <limits.h> char a[SCHAR_MAX - SCHAR_MIN + 1]; main() { return a == & SCHAR_MIN[a - SCHAR_MIN]; } Instead, GCC 1.36 (SPARCstation 1, SunOS 4.0.3c) complains: t.c: In function main: t.c:3: invalid lvalue in unary `&' The problem is that SCHAR_MIN, CHAR_MIN, and SHRT_MIN are not properly parenthesized. Here is a fix. *** old/limits.h Fri Feb 2 13:15:32 1990 --- new/limits.h Fri Feb 2 13:02:07 1990 *************** *** 5,11 **** #define MB_LEN_MAX 1 /* Minimum and maximum values a `signed char' can hold. */ ! #define SCHAR_MIN -128 #define SCHAR_MAX 127 /* Maximum value an `unsigned char' can hold. (Minimum is 0). */ --- 5,11 ---- #define MB_LEN_MAX 1 /* Minimum and maximum values a `signed char' can hold. */ ! #define SCHAR_MIN (-128) #define SCHAR_MAX 127 /* Maximum value an `unsigned char' can hold. (Minimum is 0). */ *************** *** 16,27 **** #define CHAR_MIN 0 #define CHAR_MAX 255U #else ! #define CHAR_MIN -128 #define CHAR_MAX 127 #endif /* Minimum and maximum values a `signed short int' can hold. */ ! #define SHRT_MIN -32768 #define SHRT_MAX 32767 /* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ --- 16,27 ---- #define CHAR_MIN 0 #define CHAR_MAX 255U #else ! #define CHAR_MIN (-128) #define CHAR_MAX 127 #endif /* Minimum and maximum values a `signed short int' can hold. */ ! #define SHRT_MIN (-32768) #define SHRT_MAX 32767 /* Maximum value an `unsigned short int' can hold. (Minimum is 0). */