🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2843

*_MIN lack parentheses around definiens

#2843
From: Paul Eggert
Date: Fri, 02 Feb 1990 21:19
60 lines
2065 bytes
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).  */
Technical Details
Message-ID: <9002022119.AA00745@ata.twinsun.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!twinsun.com!eggert

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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