Re: how to make gcc warn about arithmetic signed overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 23, 2013 at 1:42 PM, Oleg Endo <oleg.endo@xxxxxxxxxxx> wrote:
> On Mon, 2013-09-23 at 13:38 -0600, Dave Allured - NOAA Affiliate wrote:
>>
>> I believe the CPU overflow flag is updated after most integer
>> arithmetic instructions.  Does GCC have any facility for checking this
>> flag after each integer operation?  This would be a runtime check, of
>> course, not a compile time check.
>
> See -ftrapv option.  Although trapping math is not supported on every
> target properly.
> E.g. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35412
> or SH related http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54272

Oleg, thanks for the tip.  "-ftrapv is seriously broken and nobody
wants to fix it", and that was 5.6 years ago.  Too bad, it seems like
a useful thing when you need it.  I use gcc's -ffpe-trap routinely to
guard fortran floating point stuff, and it has done many favors for
me.

--Dave




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux