Re: Integer Overflow



On 12/31/10 10:26 AM, tm wrote:
On 30 Dez., 20:21, Ben Bacarisse<ben.use...@xxxxxxxxx> wrote:
jacob navia<ja...@xxxxxxxxxxxx> writes:
You just do not test ALL operations but only the ones where you
are interested in avoiding overflows. You use the form

if (_overflow(expression))

This is new form that, so far as I know, is unimplemented and not yet
defined. My comments may well have been different if this had been
the proposal you seemed to be putting forward.

Originally, you seemed to be suggesting a compiler intrinsic to access the
processor's overflow flag.

I think this is approach is too simple.
I use C as target language for my Seed7 to C compiler.
I would be happy if C had some overflow checking.
But I understand that there are also places where the
classic behaviour without overflow checking is needed.
I want to raise overflow exceptions (emulated with
setjmp, longjmp) in Seed7. C with overflow checking
would make this easier.

Checking the processor's overflow flag costs time and
there should be a cheaper way to handle overflows.

What could possibly be cheaper than reading a status register? If you want a software interrupt, the cost of a context switch will swamp the the cycle or two to read the status.

--
Ian Collins
.