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: Paul Schlie <schlie at comcast dot net>
- To: Robert Dewar <dewar at adacore dot com>
- Cc: Michael Veksler <VEKSLER at il dot ibm dot com>,Dale Johannesen <dalej at apple dot com>,GCC Development <gcc at gcc dot gnu dot org>,"Joseph S. Myers" <joseph at codesourcery dot com>,Mike Stump <mrs at apple dot com>,Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: Mon, 20 Jun 2005 08:08:26 -0400
- Subject: Re: basic VRP min/max range overflow question
> From: Robert Dewar <dewar@adacore.com>
> Paul Schlie wrote:
>
>> As in my mind, the semantics of foo() dictate that it print the value of
>> the storage location which was allocated to the variable "a", where unless
>> "a" is initialized with an explicit value, may be arbitrary. So I've got no
>> problem with arbitrary results or behavior, I just simply believe they are
>> implicitly constrained to the remaining rules of the language, i.e. all
>> side-effects must be expressed upon reaching a sequence point which
>> logically bounds the effects of the evaluation of any expression.
>
> This cannot be formalized, and is not what the standard says. The fact that
> you believe it is interesting (though I don't think you can write a formal
> description of what you believe in C standard terms), but we operate by what
> the standard formally says, not by what one person informally believes.
>
>> (where if an undefined behavior it did delete the program being executed it
>> wouldn't resume execution beyond the next sequence point, but if it does, it
>> must continue to abide by the languages rules regardless of the resulting
>> side effects from the preceding behaviors)
>
> Sequence points simply do not have this semantics. If they did, then nearly
> all useful optimizations would be prohibited. You are essentially positing
> a model in which the state at every sequence point is not only defined by
> the standard, but must be reflected in the implementation with no use of
> as-if semantics. I don't see this as meaningful, and I don't think this can
> be formalized. I am quite *sure* that it is undesirable.
- You may be correct, although it's not obviously the case? (As requiring
all undefined behavior be encapsulated between sequence points already
seems implied to me, as I don't see any explicit counter examples
requiring otherwise. Nor do any optimizations which are obviously more
useful than potentially counterproductive seem to require the violation of
C's sequence point semantics?)