
{: test that reading a variable from a file causes a fatal error if
   there is a range error}

{$d+}
program d042( output );

var
   f : text;
   k : integer;
   a : array[0..10] of '0'..'9';

function side : integer;
begin
   side := k;
   k := k+1;
end;
begin {d042}
   rewrite( f );
   writeln( f, '5', succ('9') );
   reset( f );

   k := 0;
   read( f, a[side] );
   if k <> 1 then
      writeln( 'read char for debug has side effects' )
   else
      read( f, a[1] ); { range error }
   writeln( 'fails: read range error not detected for char types' );
end. { d042 }

