{: test that abs(-maxint-1) causes a fatal overflow error }

program d02a( output );

var
   i, k :  integer;

function side : integer;
begin
   side := k;
   k := k+1;
end;
begin {d02a}

   k := -1;
   i := abs(side);
   if i <> 1 then
      writeln( 'unexpected value of abs(-1) is ', i );

   if k <> 0 then
      writeln( 'side effect error evaluating abs' );

   write( 'checking for abs(-maxint-1) overflow, expect runtime error ... ' );
   k := -maxint;  k := k-1; {!!! possible overflow}

   i := abs(k);    {!!! overflow}

   writeln( 'abs() overflow not detected' );

end. { d02a }

