Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!caen.engin.umich.edu!mystone From: mystone@caen.engin.umich.edu (Dean Yu) Newsgroups: comp.sys.mac.programmer Subject: Re: Bug in MPW Pascal 2.0.2 ??? Message-ID: <445d59a8.1285f@maize.engin.umich.edu> Date: 11 Jul 89 04:00:00 GMT References: <1270@draken.nada.kth.se> Reply-To: mystone@sol.engin.umich.edu Organization: Computer Aided Engineering Network, University of Michigan Lines: 43 Sender: Followup-To: In article <1270@draken.nada.kth.se> d88-bli@nada.kth.se (Bo Lindbergh) writes: >Consider the following Pascal program. > > program bug; > var > u : 0..65535; > begin > u:=60000; > writeln(u); > end. > >I can compile and link this without getting any rude messages, >but when I run it, it prints > -5536 >when it should print > 60000 >. Does anybody out there know whether this is > a) a previously known bug > b) a previously unknown bug > c) me demanding too much of the compiler? > While I can't say if this is actually a bug or not, I would like to point out that -5536 is the two's complement of 60000. If the variable u is being compiled as an integer, this would be correct. So the question is, should u have been compiled as a longint or an integer? Human logic says that the compiler should recognize that the range for u is larger than MaxInt, and should therefore make u a long integer, but the compiler might be thinking that it can store 65535 in one word and made u an integer... _______________________________________________________________________________ Dean Yu | E-mail: mystone@{sol,caen}.engin.umich.edu University of Michigan | Real-mail: Dean Yu Computer Aided Engineering Network | 909 Church St | Apt C ===================================| Ann Arbor, MI 48104 | Phone: Given on a need to know basis, and "I am the Merit Host. I speak for | only if you're going to offer me a the bitstream." (In other words, | job... these are my very own opinions; | my employer wants to have nothing |=========================================== to do with them, or me.) | This space available for rent -------------------------------------------------------------------------------