Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!twinsun.com!eggert From: eggert@twinsun.com (Paul Eggert) Newsgroups: gnu.gcc.bug Subject: *_MIN lack parentheses around definiens Message-ID: <9002022119.AA00745@ata.twinsun.com> Date: 2 Feb 90 21:19:22 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 60 The following contrived program should yield exit status 1. #include 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). */