[comp.sys.sequent] Bug in Sequent Pascal compiler

brsmith@umn-cs.CS.UMN.EDU (Brian R. Smith) (12/31/88)

I think we've found a bug in Sequent Pascal - could someone verify this?

The elements of a multi-dimensional packed arrays are not addressed
properly when they can be represented in 4 bits or less.

The real credit for this goes to Larry Lemay (lemay@umn-cs) who was just
trying to do some graphics printouts.

Example: 

 with  
var
  foo: packed array[0..7,0..7] of boolean;
{ or   array[0..7] of packed array[0..7] of boolean; - same thing.} 
 
foo[0,1] = foo[1,0], always
foo[0,2] = foo[1,1] = foo[2,0], always   
foo[0,3] = foo[1,2] = foo[2,1] = foo[3,0], always
etc.
 a 1 bit offset where there should be a 1 BYTE offset.
 
 and with
var 
  foo: packed array[0..7,0..7] of 0..3;
 
foo[0,2] = foo[1,0], always 
foo[0,3] = foo[1,1], always
foo[0,4] = foo[1,2] = foo[2,0], always   
etc.
 a 4 bit offset where there should be a 2 byte offset.

Try it.
------------------------------
program simpletest(input,output);

var
  A: array[0..7] of packed array[0..7] of 0..15;
  i,j: integer;

begin
  for i:= 0 to 7 do
    begin
      for j:= 0 to 7 do
       A[i,j]:=i+j;
    end;
  for i:= 0 to 7 do
    begin
      for j:= 0 to 7 do
        begin
          write(A[i,j]:3);
          if A[i,j]<>i+j then write('*') else write(' ');
        end;
      writeln;
    end;
end.
------------------------------

Brian
brsmith@umn-cs.cs.umn.edu
U of MN CSci dept.