This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compile with gcc option -O0 or -O


On 16/09/2011 12:05, Miles Bader wrote:
David Brown<david@westcontrol.com> writes:
... but be a bit wary of any warning option which isn't included in
-Wall or -Wextra -- they're usually omitted for a reason (typically
because they yield tons of false positives on reasonable code).

That depends on your definition of "reasonable code" !

Of course. :)


In general, though, there is some thought behind what's included in
-Wall/-Extra.  Stuff that's omitted tends to be where the warnings are
domain-specific, reflect programming practices which aren't widespread
enough, or where the gcc implementation is simply lacking in some
obvious way (sometimes it's very tricky to get the heuristics right).


Absolutely true, of course.


gcc is designed to support a huge range of code and coding practices - with that range covering different application areas, different programmer experiences and abilities, different code quality requirements, different fashions, different code sizes, and different times. It has to work well for amateur code written 20 years ago and aeroplane-quality code written to modern standards. So the -Wall and -Wextra groups are picked to give a reasonable compromise, and the individual flags are there for people who want more control.

-Wpadded, for instance, may be very interesting for embedded devs, but
probably not so much for many others, and yields vast quantities of
warnings on "ordinary" code.

-Wfloat-equal, on the other hand, reflects a rule of thumb which is very
useful when applied intelligently (i.e., by a human), but is less well
suited to automatic application.  [Testing for floating-point equality
is unreliable if the values being tested are the result of calculation,
but _is_ reliable if the values are the result of simple assignment,
especially certain values like 0.0 -- and the compiler is very unlikely
to be able to distinguish these cases.  If you _know_ that your
code-base never, ever, tests equality in the latter case, you can safely
use -Wfloat-equal, but this isn't something that can be relied upon.]

<etc etc blah blah>

-miles




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]