pollock@usfvax2.EDU (Wayne Pollock) (10/29/88)
Below is a LSP program (re-pretty-printed to save screen space; why oh why
can't I turn this option off?). The two copies are identical except for the
keyword "packed" in the type statement. Was this ever a tough bug to find!
(I thought I had an error in my program, which was over 1300 lines long.)
PROGRAM mojo (output);
TYPE y = RECORD
a : integer;
b : 0..2047
END;
VAR x : y;
BEGIN
x.b := 255; writeln(x.b);
x.b := 256; writeln(x.b);
x.b := 257; writeln(x.b)
END.
(************************** GOOD RESULTS ***********************)
255
256
257
PROGRAM mojo (output);
TYPE y = PACKED RECORD
a : integer;
b : 0..2047
END;
VAR x : y;
BEGIN
x.b := 255; writeln(x.b);
x.b := 256; writeln(x.b);
x.b := 257; writeln(x.b)
END.
(************************** BAD RESULTS ***********************)
255
0
1
Anyone know a fix for this? It seems that by packing a subrange, LSP
allocates only one byte for the range even if the size of the range is
greater than 256!
Wayne Pollock (The MAD Scientist) pollock@usfvax2.usf.edu
Usenet: ...!{uflorida, codas}!usfvax2!pollock
GEnie: W.POLLOCK