This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: basic VRP min/max range overflow question
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Paul Schlie <schlie at comcast dot net>
- Cc: Dale Johannesen <dalej at apple dot com>, Robert Dewar <dewar at adacore dot com>, Mike Stump <mrs at apple dot com>, Andrew Pinski <pinskia at physics dot uc dot edu>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Sat, 18 Jun 2005 16:19:23 +0000 (UTC)
- Subject: Re: basic VRP min/max range overflow question
- References: <BED9A4B3.A88B%schlie@comcast.net>
On Sat, 18 Jun 2005, Paul Schlie wrote:
> Maybe I didn't phrase my statement well; I fully agree with the cited
> paragraph above which specifically says a program containing unspecified
> behavior "shall be a correct program and act in accordance with
> 5.1.2.3". Which specifies program execution, in terms of an abstract machine
> model, which correspondingly requires:
You appear to have confused unspecified behavior (where the possibilities
are bounded) and undefined behavior (where the possibilities are
unbounded). On *undefined* behavior (such as signed integer overflow),
*this International Standard imposes no requirements*. If a program
execution involved undefined behavior, *there are no requirements on its
execution, even before the undefined behavior occurs in the abstract
machine*. Therefore the compiler assumes that you only ever pass it
programs which do not execute undefined behavior. If a possible execution
might involve undefined behavior, the compiler presumes that the
programmer knows more than it can prove and knows that the relevant
circumstances cannot arise at execution. For example, a correct program
never involves overflow of a signed loop variable, so the compiler
presumes that the programmer proved that the loop variable can never
overflow at execution and uses this information to optimize the loop: it
cannot prove it by itself but using the presumption that the program is
correct it can optimize the program better.
The traditional form of undefined behavior is for demons to fly out of
your nose. We just haven't yet got -fnasal-demons working reliably but it
would be conforming for it to be on by default. If you are lucky, it will
happen anyway without that option.
http://groups.google.com/groups?hl=en&selm=10195%40ksr.com
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)