Path: 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 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: