[Bug c++/30245] -O2 generates bad code

dcb314 at hotmail dot com gcc-bugzilla@gcc.gnu.org
Tue Dec 19 12:34:00 GMT 2006



------- Comment #7 from dcb314 at hotmail dot com  2006-12-19 12:34 -------
(In reply to comment #6)
> In that case, you might want to read the C++ standard text to
> appreciate the facts.

There is a strange sort of echo in this bug report ;->

I accept the point that the code is undefined, according to
the standard and so the compiler is allowed to do anything.

However, the point remains that some perfectly reasonable,
but non standard, code has had its executable action
silently changed in the last few weeks at the -O2 optimisation
level.

This then becomes a quality of implementation issue:

Is it reasonable and prudent to have tests like "if (n == 0)"
optimised away at the -O2 optimisation level ?

We should remember that -O2 is heavily used by lots of
customers.

Some customers might argue that the old behaviour was fine at 
-O2 and such a tense optimisation should only be available at 
higher optimisation levels or moved into a special flag that the 
user can set if they want to from the command line.

There is a clear tradeoff here. If the new behaviour remains,
I suspect the flag -fwrapv will be a popular flag ;->


-- 

dcb314 at hotmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30245



More information about the Gcc-bugs mailing list