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.

Reply via email to