Path: utzoo!attcan!uunet!husc6!bloom-beacon!oberon!cit-vax!elroy!mahendo!jplgodo!wlbr!scgvaxd!ashtate!dbase!drc From: drc@dbase.UUCP (Dennis Cohen) Newsgroups: comp.sys.mac.programmer Subject: Re: MPW Pascal Bug? Or am I wrong. Message-ID: <383@dbase.UUCP> Date: 20 Jun 88 17:50:31 GMT References: <3203@polyslo.UUCP> Organization: Ashton Tate Development Center Glendale Cal. Lines: 27 In article <3203@polyslo.UUCP>, dorourke@polyslo.UUCP (David O'Rourke) writes: > procedure doSomething; > var > X, Y : INTEGER; > Z : LONGINT; > begin > Z := X * Y; > end; {doSomething} > > If X*Y causes an overflow and I have overflow checking turned off it stores > the wrong result, usually negative, in Z even though Z is a LONGINT. Now is > this what the compiler is suppose to do, or is it suppose to convert to the > LONGINT. > No, unfortunately this is exactly what the compiler is "supposed" to do (read that "is documented to do"). The coercion is not done until the assignment is made and by then it is too late. If either of the arguments had been a Longint, the problem would not arise as it would have done a long multiply rather than a word multiply. I, too, would like the compiler to be smarter in this instance but don't expect that this will change. Dennis Cohen Ashton-Tate Macintosh Division dBASE Mac Development Team -------------------------- Disclaimer: Any opinions expressed above are _MINE_!