This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC optimizes integer overflow: bug or feature?
- From: Robert Dewar <dewar at adacore dot com>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: Brooks Moses <brooks dot moses at codesourcery dot com>, gcc at gcc dot gnu dot org, bug-gnulib at gnu dot org
- Date: Tue, 19 Dec 2006 06:46:55 -0500
- Subject: Re: GCC optimizes integer overflow: bug or feature?
- References: <45879F28.1000400@adacore.com> <20061219114104.GA7453@atrey.karlin.mff.cuni.cz>
Zdenek Dvorak wrote:
IMHO, using loops relying on the behavior of overflow of an
induction variable (*) is an ugly hack and whoever writes such a code
does not deserve for his program to work.
I suspect everyone would agree on this, and in practice I would
guess that
a) there are no programs that rely on this
b) the value of the optimization if any, is probably almost all
from this treatment of induction variables in loops.
Perhaps the proper resolution here is to implement and document
that gcc will wrap except in the case of loop variables (needs
some more careful documentation of course).