[Bug middle-end/49283] pointless warning with -Wstrict-overflow

bruno at clisp dot org gcc-bugzilla@gcc.gnu.org
Mon Jun 6 20:33:00 GMT 2011


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

--- Comment #3 from bruno at clisp dot org 2011-06-06 20:33:07 UTC ---
(In reply to comment #2)
> [GCC] optimizes [...]
> moving the + 3 from the LHS and combining it with the constant offset
> on the RHS.  That is only valid if p + 3 does not get outside of buff
> which GCC doesn't see

Rather than performing an invalid optimization (that is, produce wrong-code)
with a warning, I would prefer if GCC would simply only do valid optimizations.

Code ought to be written to be maintainable. If code has to be changed, so
as to avoid invalid optimizations from a compiler, then
1. it becomes a lot of work to change the code so that all compilers on all
   supported platforms are pleased,
2. the maintainability of the code suffers.

I did not enable particular, dangerous optimization options. Just "-O2",
which is the default setting in every package that uses autoconf.



More information about the Gcc-bugs mailing list