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

{$d+}
program d048( output );

const
   testCh = 'K';
var
   f : text;
   k : integer;
   a : array[0..10] of char;

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

   k := 0;
   read( f, a[side] );
   if k <> 1 then
      writeln( 'read char for debug has side effects' )
   else if a[0] <> testCh then
      writeln( 'expected ', testCh:1, ' found ', a[0] );
   read( f, a[1] ); { skip eoln at end }

   read( f, a[2] ); { file error }
   writeln( 'fails: read char file error not detected' );
end. { d048 }

