home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!ogicse!news.u.washington.edu!byron.u.washington.edu!nobby
- From: nobby@byron.u.washington.edu (Vitaly Shmatikov)
- Newsgroups: comp.lang.pascal
- Subject: Re: I found a compiler bug in TP6.0, maybe...
- Message-ID: <1992Nov23.061222.3675@u.washington.edu>
- Date: 23 Nov 92 06:12:22 GMT
- Article-I.D.: u.1992Nov23.061222.3675
- References: <1992Nov22.192602.16440@crash>
- Sender: news@u.washington.edu (USENET News System)
- Organization: University of Washington, Seattle
- Lines: 44
-
- In article <1992Nov22.192602.16440@crash> tech@crash.cts.com (Don Bontemps) writes:
- >
- >When I attempt to compile the following code, I get a runtime error 202.
- >It appears that I am getting an array range check error but the array index
- >is within range. Here an example code listing:
- >
- >program range_bug;
- >
- >
- >{ Author: Donald P. Bontemps Jr.
- > Date: November 22, 1992 }
- >
- >
- >const
- >
- > days : array [-1..6] of string[10] = (' ','Sunday','Monday','Tuesday',
- > 'Wednesday','Thursday','Friday',
- > 'Saturday');
- >
- > num : word = 0;
- >
- >
- >begin
- >
- > writeln(days[num-1]);
- >
- >end.
- >
- >
-
- Just a guess: when num-1 is evaluated the result is coerced to the
- type of num, i.e. word. -1 is 2^16-1 if treated as word. Range error is
- raised while trying to dereference days[2^16-1]. Looks like perfectly normal
- compiler behaviour.
-
- >
- >
- >If I turn off the compiler range checking (ie: {$R-}) the program
- >executes just fine. The example code is a small portion of a large application
- >that I am currently writing. If I declare num as an integer, this fixes the
- >error but I need num to be declared as a word. So what gives? Is this a
- >bonafide compiler bug or what? Thanks for the feedback.
-
- nobby@u.washingon.edu
-