New option?
Sam Lauber
sam124@operamail.com
Sat Jan 29 18:28:00 GMT 2005
I think an option -ftrapping-integer-math should be added
to GCC that generates calls to the libgcc functions
__XXXvdiX and ___XXXvsiX that call `abort()' for overflow
instead of calls to the regular assembly instructions for
that task. I.e. on x86, to add ebx + ebx into eax, instead
of
addl %ebx, %ebx
movl %ebx, %eax
it would do
pushl %ebx
pushl %ebx
call __addvsi2
popl %eax
That would create runtime overhead for normal programs, and
a *lot* of runtime overhead for alogrithms but it would
prevent overflow from causing unpredictable results
(-finline-libgcc-functions anyone ;-). But considering
that most programs (and even most alogrithms) use a fair
amount of constants, constant folding will reduce that
overhead.
Samuel Lauber
--
_____________________________________________________________
Web-based SMS services available at http://www.operamail.com.
From your mailbox to local or overseas cell phones.
Powered by Outblaze
More information about the Gcc
mailing list