home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pascal / 6825 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  1.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!ogicse!news.u.washington.edu!byron.u.washington.edu!nobby
  2. From: nobby@byron.u.washington.edu (Vitaly Shmatikov)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: I found a compiler bug in TP6.0, maybe...
  5. Message-ID: <1992Nov23.061222.3675@u.washington.edu>
  6. Date: 23 Nov 92 06:12:22 GMT
  7. Article-I.D.: u.1992Nov23.061222.3675
  8. References: <1992Nov22.192602.16440@crash>
  9. Sender: news@u.washington.edu (USENET News System)
  10. Organization: University of Washington, Seattle
  11. Lines: 44
  12.  
  13. In article <1992Nov22.192602.16440@crash> tech@crash.cts.com (Don Bontemps) writes:
  14. >
  15. >When I attempt to compile the following code, I get a runtime error 202.
  16. >It appears that I am getting an array range check error but the array index
  17. >is within range.  Here an example code listing:
  18. >
  19. >program range_bug;
  20. >
  21. >
  22. >{ Author: Donald P. Bontemps Jr.
  23. >    Date: November 22, 1992      }
  24. >
  25. >
  26. >const
  27. >
  28. >  days : array [-1..6] of string[10] = (' ','Sunday','Monday','Tuesday',
  29. >                                        'Wednesday','Thursday','Friday',
  30. >                                        'Saturday');
  31. >
  32. >  num : word = 0;
  33. >
  34. >
  35. >begin
  36. >
  37. >  writeln(days[num-1]);
  38. >
  39. >end.
  40. >
  41. >
  42.  
  43. Just a guess: when num-1 is evaluated the result is coerced to the
  44. type of num, i.e. word. -1 is 2^16-1 if treated as word. Range error is
  45. raised while trying to dereference days[2^16-1]. Looks like perfectly normal
  46. compiler behaviour.
  47.  
  48. >
  49. >
  50. >If I turn off the compiler range checking (ie: {$R-}) the program
  51. >executes just fine.  The example code is a small portion of a large application
  52. >that I am currently writing.  If I declare num as an integer, this fixes the
  53. >error but I need num to be declared as a word.  So what gives?  Is this a
  54. >bonafide compiler bug or what?  Thanks for the feedback.
  55.  
  56. nobby@u.washingon.edu
  57.