O3 versus O2 weirdness
John Love-Jensen
eljay@adobe.com
Mon Apr 16 15:14:00 GMT 2007
Hi Bartlomiej,
>> Maybe. Did you have all the warnings turned on?
> by means of -Wall ? yes, they were turned on
Not merely -Wall, which ironically does not enable all the warnings.
But actually enable all the warnings (less whichever ones you've decided
can/should be ignored)?
Note: GCC does not have -Wall-really-all-I-really-really-mean-it flag. You
have to enable many warnings by hand. (Most people probably wouldn't want
ALL those picayune warnings enabled, especially since the standard header
files themselves generate a lot of warnings.) GCC does not -- and likely
never will -- have a "enable all warnings" flag.
I enable almost all warnings, with the exceptions of:
-Wno-unreachable-code # templates generate bazillion warnings
-Wno-long-long # "long long" 64-bit integer language extension
-Wno-four-char-constants # 'ABCD' 32-bit four-char-code language extension
-Wno-aggregate-return # objects as return types
-Wno-system-headers # system headers are noisy, otherwise
... parameterized warnings, e.g., -Wlarger-than-<len>
... and all the non-C++ warnings (since I program in C++)
The warnings I enable accounts for about 140 lines of my Makefile.
> it seems that more aggressive optimisation triggers code bugs, maybe it
> could be used for bug finding itself ?
Which is what the warning flags do. They help detect questionable code.
(Caution: sometime too many spurious warnings.)
But warnings alone cannot prevent bad code. Bad code can be written in any
language.
Sincerely,
--Eljay
More information about the Gcc-help
mailing list