This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Go patch committed: Add explicit checks for division zero and overflow
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Tue, 24 Apr 2012 21:38:34 +0000 (UTC)
- Subject: Re: Go patch committed: Add explicit checks for division zero and overflow
- References: <mcrd3728ay8.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
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