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

{$d+}
program d044( output );

const
   testInt = 783;
var
   f : text;
   k : integer;
   a : array[0..10] of integer;

function side : integer;
begin
   side := k;
   k := k+1;
end;
begin {d044}
   rewrite( f );
   writeln( f, testInt, '.412' );
   reset( f );

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

   read( f, a[1] ); { format error }
   writeln( 'fails: read integer format error not detected' );
end. { d044 }

