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

{$d+}
program d040( output );

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

function side : integer;
begin
   side := k;
   k := k+1;
end;
begin {d040}
   rewrite( f );
   writeln( f, 90, 100 );
   reset( f );

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

