This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to make gcc warn about arithmetic signed overflow


On 09/23/2013 08:38 PM, 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.

It wouldn't help with optimized code.  GCC reorganizes code, and it
assumes that overflow doesn't happen.  GCC inserts some arithmetic
instructions while optimizing and deletes others.  So, even if an
overflow happens in your code, it doesn't necessarily happen at
runtime.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]