🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2842

INT_MIN should be negative

#2842
From: Paul Eggert
Date: Fri, 02 Feb 1990 20:52
30 lines
1416 bytes
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).  */
Technical Details
Message-ID: <9002022052.AA00646@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: INT_MIN should be negative
Message-ID: <9002022052.AA00646@ata.twinsun.com>
Date: 2 Feb 90 20:52:04 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 30