🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #40922

Re: Bug in TURBO-C V1.0

#40922
From: HC Johnson
Date: Thu, 15 Feb 1990 14:01
30 lines
1311 bytes
In article <1990Feb14.173746.28244@agate.berkeley.edu>, ericco@stew.ssl.berkeley.edu (Eric C. Olson) writes:
> >Look at this C-code:
> >    #define MAX  -32768
> >    main()
> >    {
> >    printf("1: %d\n", MAX);
> >    printf("2: %d\n", (int)MAX);
> >    }
> 
> This is not a bug, its a feature.  MAX is not a number, its an expression.
> Thus, the evaluation of MAX is a long int.  The first printf only prints

K&R specify that constants are int's.  Not a long int.

> the high word of the long int MAX.  The second printf properly casts the
> long int to an int and prints the correct result.  Try:
> 
> 	printf("3: %ld\n", MAX);
> 
This is probably an example of the compiler maker trying to be nice.
And breaking the users code in the process.


Howard C. Johnson
ATT Bell Labs
=====NEW address====
att!lzsc!hcj
hcj@lzsc.att.com

stupid mailer:
Technical Details
Message-ID: <1302@lzsc.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!dptg!lzsc!hcj
References: <8910270333.AA14741@cscwam.UMD.EDU> <0927891128429423@thelake.UUCP> <1990Feb14.173746.28244@agate.berkeley.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!dptg!lzsc!hcj
From: hcj@lzsc.ATT.COM (HC Johnson)
Newsgroups: comp.sys.atari.st
Subject: Re: Bug in TURBO-C V1.0
Summary: its not K&R
Message-ID: <1302@lzsc.ATT.COM>
Date: 15 Feb 90 14:01:53 GMT
References: <8910270333.AA14741@cscwam.UMD.EDU> <0927891128429423@thelake.UUCP> <1990Feb14.173746.28244@agate.berkeley.edu>
Organization: AT&T BL Middletown/Lincroft NJ USA
Lines: 30