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

{$d+}
program d045( 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 {d045}
   rewrite( f );
   writeln( f, testReal, 'e3' );
   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] ); { format error }
   writeln( 'fails: read real format error not detected' );
end. { d045 }

