This is the mail archive of the gcc-patches@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: Go patch committed: Add explicit checks for division zero and overflow


On Fri, 20 Apr 2012, Ian Lance Taylor wrote:

> In Go, a division overflow is supposed to wrap.  On x86 processors it
> would raise a SIGFPE signal leading to a panic.  This patch fixes that
> problem as well.

It's a pity that this change is Go-specific.  For -fwrapv, INT_MIN / -1 
and INT_MIN % -1 should both have defined modulo semantics for C and C++ 
(similarly of course for all signed integer types, not just int).  Ideally 
of course the semantics for this would be encoded properly in GENERIC / 
GIMPLE, but until then it would make sense to have a global flag, set by 
both -fwrapv and the Go front end, to enable those checks in the 
language-independent compiler.  See bug 30484.

-- 
Joseph S. Myers
joseph@codesourcery.com


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