Re: Integers and standard



Steven G. Kargl wrote:
(snip)

Do you really want a compiler to automatically instrument the
following code to catch overflow

function add(i,j)
integer add
integer, intent(in) :: i, j
add = i + j
end function add

where add() may be called several hundered trillion times?
If you want this capability, send a bug report requesting
an option similar to -ffpe-trap, which is used with floating
point exceptions.

The PL/I way (not that I am suggesting Fortran implement
it) is to allow one to specify at the procedure level or
statement level (overriding the procedure level) to enable
or disable such checks.

(fixedoverflow): add = i + j; /* enable overflow check */

(nozerodivide): q=i/j; /* disable divide by zero check */

For IA32, overflow check adds an INTO instruction after each
that could overflow.

-- glen

.


Quantcast