This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- From: Robert Dewar <dewar at adacore dot com>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>, dewar at adacore dot com, autoconf-patches at gnu dot org, bernds_cb1 at t-online dot de, bug-gnulib at gnu dot org, ebb9 at byu dot net, eggert at cs dot ucla dot edu, gcc at gcc dot gnu dot org, gdr at integrable-solutions dot net, pinskia at physics dot uc dot edu, richard dot guenther at gmail dot com
- Date: Sun, 31 Dec 2006 10:07:44 -0500
- Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- References: <200612310042.kBV0g5pt027400@localhost.localdomain> <45970D3D.1090700@adacore.com> <20061231120933.GS32297@ay.vinc17.org> <4597B5F0.5050504@adacore.com> <10612311408.AA19449@vlsi1.ultra.nyu.edu> <20061231144821.GW32297@ay.vinc17.org>
Vincent Lefevre wrote:
If done in unsigned, this won't lead to any optimization, as unsigned
arithmetic doesn't have overflows. So, if you write "a - 10" where a
is unsigned, the compiler can't assume anything, whereas is a is
signed, the compiler can assume that a >= INT_MIN + 10, reducing
the range for a, and possibly allowing some optimizations.
Vincent, you missed the point, if we do this in unsigned, it works
fine, and we don't WANT any optimization to intefere. That's what
Richard was saying, if you want to do this kind of hand optimization
of range checking, you do it in unsigned, and everything is fine.
If you do it in signed expecting wrapping, then the optimization
destroys your code. Yes, it is technically your fault, but this
business of telling users
"sorry, your code is non-standard, gcc won't handle it as you
expect, go fix your code"
is not very convincing to users who find other compilers that
handle their code just fine.
I remember that in Realia COBOL days, it was not just a matter
of dealing with undefined situations, there were actually a
couple of cases where the IBM compiler had semantics that were
definitely non-conforming to the COBOL standard. Users depended
on these bugs, so we carefully copied them in Realia COBOL.
Sure, we could have explained to users that their code was
junk, and the IBM compiler was wrong, but that would not have
convinced them to move to using Realia COBOL!