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

  1. Path: sparky!uunet!nwnexus!abyss!milton
  2. From: milton@abyss.wa.com (Steve Milton, Sysop)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: I found a compiler bug in TP6.0, maybe...
  5. Message-ID: <JgLouB1w165w@abyss.wa.com>
  6. Date: Sun, 22 Nov 92 23:32:18 PST
  7. References: <1992Nov23.061222.3675@u.washington.edu>
  8. Organization: ISOMEDIA, Inc.
  9. Lines: 33
  10.  
  11. nobby@byron.u.washington.edu (Vitaly Shmatikov) writes:
  12.  
  13. > In article <1992Nov22.192602.16440@crash> tech@crash.cts.com (Don Bontemps) w
  14. > >
  15. > >When I attempt to compile the following code, I get a runtime error 202.
  16. [Some lines deleted.]
  17. > >
  18. > >  num : word = 0;
  19. > >
  20. > >
  21. > >begin
  22. > >
  23. > >  writeln(days[num-1]);
  24. > >
  25. > >end.
  26. > >
  27. > >
  28. > Just a guess: when num-1 is evaluated the result is coerced to the
  29. > type of num, i.e. word. -1 is 2^16-1 if treated as word. Range error is
  30. > raised while trying to dereference days[2^16-1]. Looks like perfectly normal
  31. > compiler behaviour.
  32.  
  33. It is even simpler than that.  WORD is defined as an unsigned value.  
  34. change num to an integer type and it may work.  (I have never used 
  35. negative values for array ranges, so I'm not sure pascal even allows 
  36. them, but try as you like.).
  37.  
  38.  
  39. +---------------------------------------------------------------------------+
  40. | Stephen Milton, Sysop of `The Abyss UUCP BBS & Mail Feed'   Bellevue, WA. |
  41. | Internet: milton@abyss.wa.com                  UUCP: nwnexus!abyss!milton |
  42. +---------------------------------------------------------------------------+
  43.