Path: utzoo!attcan!uunet!clyde.concordia.ca!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!oracle!news From: mroberts@oracle.oracle.com (Mike Roberts) Newsgroups: comp.sys.atari.st Subject: Re: Bug in TURBO-C V1.0 Message-ID: <1990Mar2.194928.6523@oracle.com> Date: 2 Mar 90 19:49:28 GMT References: <8910270333.AA14741@cscwam.UMD.EDU> <0927891128429423@thelake.UUCP> <1990Feb14.173746.28244@agate.berkeley.edu> <1302@lzsc.ATT.COM> <1990Feb19.092139.3131@pcsbst.pcs.com> <1990Feb21.204744.560@agate.berkeley.edu> <8098@sdcc6.ucsd.edu> Reply-To: mroberts@oracle.com (Mike Roberts) Organization: Oracle Corporation, Belmont, CA Lines: 26 In article <8098@sdcc6.ucsd.edu> mce@sdcc10.ucsd.edu (Mark Edwards) writes: > [...example and much discussion deleted...] >#Like I said "MAX is not a number, its an expression." There is an integer >#in the expression (the number 32768). But there is also an operator (the >#unary minus). This makes MAX an expression, not a number. Thus the real >#question is what does K&R say integer expression are evaluated to? I >#don't have K&R handy, but I believe it says long ints. ># > [...more discussion deleted...] >IMHO, MAX is a constant expression. Since its type is unspecified, it is an >int. Since it is not specified as unsigned, and is an integral type, it is >therefore a signed type. Together the conclusion that MAX is a >"const signed int MAX" when all the defaults are considered. > [...yet more deleted...] The ANSI C draft, section 3.1.3.2 "Integer constants," says that type of an unsuffixed integer constant (i.e., no "L" or "U" suffix) is the first type from the following list big enough to hold the constant: int, long int, unsigned long int. I don't know how Turbo implements int on a 68k; the "natural" word size of a 68k is somewhat ambiguous, since the processor handles 16- and 32-bit computations equally well. If Turbo uses 16-bit int's, 32768 is promoted to long because it does not fit in an int; the "-" operator is then applied to the long, which results in a long. If Turbo uses 32-bit int's, 32768 fits in an int and no promotion takes place; applying the "-" operator does not result in any promotion, either, since, when it is applied to an int, and int results (see the draft, section 3.2 and 3.3).