{: test that arithmetic overflow causes a fatal error }

{$d+}
program d095( output );

var
   k : integer;

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

   k := 10;
   writeln( '-10*10 is ', -10*side:1);
   if k <> 11 then
      writeln( 'multiply operator for debug has side effects' );

   k := -maxint div 2;
   writeln( k:1, '*2 is ', 2*k );
   k := k-1;
   writeln( k:1, '*2 is ', 2*k ); { might overflow, or might not }
   k := k-1;
   writeln( k:1, '*2 is ', 2*k ); { definitely should overflow }
   writeln( 'fails: overflow in multiply operator error is not detected' );
end. { d095 }

