Article View: comp.std.c
Article #3105Greenhills "C" compiler (casting int's)
From: David R. Trinidad
Date: Wed, 05 Jun 1991 21:21
Date: Wed, 05 Jun 1991 21:21
37 lines
1671 bytes
1671 bytes
1. I just received a reply from the Greenhills people on the
following code .. which compiles and runs correctly on AT&T,
mircosoft, borland and SCO:
#include <stdio.h>
#include <limits.h>
int intermediate = 100;
main()
{
if (intermediate > USI_MAX -1 ) printf("this is a bug");
if ((unsigned)intermediate > USI_MAX -1 ) printf("this works");
}
2. The response from GREENHILLS:
If a operand is unsined int , the second is converted in unsigned
int (sic).
If an operand is int the second is converted in int (signed)
[(sic)]
To get a correct value you must cast the first value to unsigned.
3. AT&T .... promotes the first value to unsigned if the second
operator is unsigned therfore correctly comparing the if
statment.
4. The question is : What is the standard ? K+R, and ANSI
Direct answers to either this posting or preferably E-MAIL
below.
************************************************************************
Organization: Cycare Systems
Internet : drt%cysog@hbiso.ma02.bull.com
UUNET: uunet!hbiso!cysog!drt
Phone: (602) 224 0555 | FAX: (602) 224 0872
System: B.O.S. UNIX |
UNIX isn't just an OS | It's a way of life !!!!!
***********************************************************************
Technical Details
Message-ID:
<510@cysog.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!hbiso!cysog!drtShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!hbiso!cysog!drt From: drt@cysog.UUCP (David R. Trinidad) Newsgroups: comp.std.c Subject: Greenhills "C" compiler (casting int's) Summary: Question on the casing of int's Keywords: int unsigned standard "C" Message-ID: <510@cysog.UUCP> Date: 5 Jun 91 21:21:46 GMT Organization: CyCare Systems Inc., Phoenix,AZ Lines: 37