
{: test that the pack function causes a fatal error if
   there is a range error with a conformant array parameter }

{$d+}
program d108( output );

type lowCase =  'a'..'z';
var
   a  : array['a'..'z'] of lowCase;
   pa : packed array[1..4] of char;
   c  : char;

function side : char;
begin
   side := c;
   c := succ(c);
end; { side }

procedure p( a : array[c0..c1 : char] of lowCase;
             pa : packed array[i0..i1 :integer ] of char
            );
begin
   c := 'w';
   unpack( pa, a, side );
   if c <> 'x' then
      writeln( 'unpack for debug has side effects' );

   c := 'x';
   unpack( pa, a, c ); { range error }
   writeln( 'fails: unpack range error not detected' );
end; { p }

begin {d108}
   pa := 'LION';
   p(a, pa);
end. { d108 }

