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: "Joseph S. Myers" <joseph at codesourcery dot com>,Dale Johannesen <dalej at apple 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: Mon, 20 Jun 2005 07:13:33 -0400
- Subject: Re: basic VRP min/max range overflow question
> From: Robert Dewar <dewar@adacore.com>
> Paul Schlie wrote:
>
>> My position is simply that an optimization should never remove a specified
>> operation unless it is known to yield logically equivalent behavior, as
>> producing a program which does not behave as specified is not a good idea
>
> That may be your position, but it is not the position of the standard, and
> indeed it is not a well-formed position. Why, because the whole point is that
> when the behavior is undefined, then the change DOES yield a logically
> equivalent behavior, because undefined means undefined, and all possible
> behaviors are logicaly equivalent to undefined.
>
> Note that in the cases where something is statically optimized away (these
> are the easy cases), it is nice if the compiler warns that this is happening
> (that would certainly be the case in Ada in the corresponding situation, not
> sure about C++). But of course no such warning is required.
Agreed. And given that the standard enables an implementation to do anything
upon encountering an undefined behavior, it just seems just as correct to
simply presume that the behavior will be consistent with the targets native
behavior; as just because it may enable the compiler to do anything, it
doesn't imply that it should, or that it would be a good idea to do so.