This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Constant fold -A - B as -B - A (take 2)
- From: Fergus Henderson <fjh at cs dot mu dot OZ dot AU>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: roger at www dot eyesopen dot com, gcc-patches at gcc dot gnu dot org
- Date: Tue, 11 Feb 2003 02:40:13 +1100
- Subject: Re: [PATCH] Constant fold -A - B as -B - A (take 2)
- References: <10302080306.AA04065@vlsi1.ultra.nyu.edu>
On 07-Feb-2003, Richard Kenner <email@example.com> wrote:
> There is *no* language, as far as I know, for which MAX_INT + 1 is defined,
> let alone equal to MIN_INT.
What about Java, C#, and Visual Basic?
In Java, integers have finite precision with two's complement-style ranges
(i.e. MIN_INT = -MAX_INT - 1), and integer overflow always wraps.
So yes, MAX_INT + 1 is defined to be equal to MIN_INT (presuming
appropriate definitions of MAX_INT and MIN_INT, of course).
[JLS 4.2.2 says "the operation is carried out using 32-bit precision" and
"The built-in integer operators do not indicate overflow or underflow in
In C#, there are "checked" contexts and "unchecked" contexts;
in the former, integer overflow always raises an exception,
but in the latter, integer overflow always wraps, just like in Java.
For VB, it's the same as for C#.
Fergus Henderson <firstname.lastname@example.org> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.