{: test that sqrt(x) causes a fatal error if x < 0 }

{$d+}
program d085( output );

var
   e,k : real;

function side : real;
begin
   side := k;
   k := k+1;
end;
begin {d085}

   k := 1;
   writeln( 'sqrt(1) is ', sqrt(side):1:1);
   if k <> 2 then
      writeln( 'sqrt() for debug has side effects' );

   k := 0;
   writeln( 'sqrt(0) is ', sqrt(k):1:1 );

   k := 1;
   while k > 0 do begin
      e := k;
      k := k/2;
   end;
   writeln( 'sqrt(eps) is ', sqrt(e):9 );
   writeln( 'sqrt(-eps) is ', sqrt(-e):9 ); {error}
   writeln( 'fails: sqrt < 0 error is not detected' );
end. { d085 }

