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

{$d+}
program d047( output );

const
   testReal = 783.25;
var
   f : text;
   k : integer;
   a : array[0..10] of real;

function side : integer;
begin
   side := k;
   k := k+1;
end;
begin {d047}
   rewrite( f );
   write( f, testReal );
   reset( f );

   k := 0;
   read( f, a[side] );
   if k <> 1 then
      writeln( 'read char for debug has side effects' )
   else if a[0] <> testReal then
      writeln( 'expected ', testReal:1, ' found ', a[0] );

   read( f, a[1] ); { file error }
   writeln( 'fails: read real file error not detected' );
end. { d047 }

