Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!apple!oliveb!mipos3!omepd!inteloa!prl From: prl@inteloa.intel.com (Philip Lantz) Newsgroups: comp.lang.c Subject: Re: long conversion of short expression. Message-ID: <4750@omepd.UUCP> Date: 3 Aug 89 03:48:59 GMT References: <9092@chinet.chi.il.us> <18795@mimsy.UUCP> Sender: news@omepd.UUCP Reply-To: prl@inteloa.UUCP (Philip Lantz) Organization: Biin, Hillsboro, Oregon Lines: 21 In article <18795@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: > The result of shortvar*shortvar has type int. > ... If the result overflows, the value is undefined; a clever > int-is-16-bits-style 68000 compiler may produce the correct value by > noticing that the 68000 `muls' instruction produces a 32 bit result, > and carrying that around even though its result type (int) was supposed > to have been only 16 bits. This is not required by any C standard, > but is permitted since the result value is undefined. I agree that if the multiplication overflows, the result is undefined, but its type is still an int; if a later conversion to long is required, isn't the compiler required to perform the 'extl' anyway? That is, shouldn't the result of a conversion from int to long be in the numeric range of an int, even if the original int value was undefined? Or is the compiler free to do whatever it likes with an entire expression if any sub-expression overflows? Philip Lantz P.S. Sorry to pick nits, Chris; your articles are without fail the most accurate and informative in this newsgroup.