
{: test that trunc(x) causes a fatal error if it overflows }

{$d+}
program d022( output );

var
   x :  real;

function side : real;
begin
   side := x;
   x := x+1;
end;
begin {d022}
   x := maxint+0.9;
   writeln( 'maxint is ', trunc(side):1 ); { this should not overflow }
   if abs(x - (maxint+0.9+1)) > 0.5 then
      writeln( 'side effect error evaluating trunc' );
   writeln( 'maxint+1 is ', trunc(x+1):1 ); { this should overflow }
end. { d022 }

