-Wmissing-pure/-Wmissing-const/-Wmissing-nothrow

Jan Hubicka hubicka@ucw.cz
Sun Jul 5 10:05:00 GMT 2009


> These paragraphs need a few more definite articles (`a' and `the'), and
> contain at least one typo (easilly).  I'd review more closely, but I
> suppose it needs to be rewritten for semantics anyway.
> 
> I have a nit with the proposed semantics:
> 1) The warning gets more effective with higher optimization levels.
> This sounds good (and normal) to me.
> 2) The warning is not produced for functions where the compiler can fully
> decide by itself, and
> 3) Presumably, the compiler gets or at least could get more intelligent
> about fully deciding by itself with higher optimization levels.
> 
> Is (3) true now?  Could it be true at some point in the future?  If yes,
> it means that possibly, candidates may not be detected fully by the
> compiler for, say, -O1, which are however also not warned about by -O2
> and higher.  That means, in order to find all possibly useful

Well, the compiler warns primarily about externally visible functions
(i.e. cases where functions can be called from other unit where compiler
don't know the body). Visibility is not affected by optimization levels.
This means that with -O2 you get more warnings than -O1 except for very
rare cases where compiler manages to somehow completely confuse itself
by its own optimizations.

There is also warning in case compiler can not prove finiteness of
function. This can also vary based on optimization level (i.e. you
really can have fewer warnings at -O2 than at -O1 in case compiler does
better job).  Also if you add stuff like -fstrict-owerflow you get
more functions provably finite.

Neither of those are too important in practice however - both pure and
const functions are simple, so the compiler is quite effective on
detecting them on all levels.  Same can be told about all optimization
based warnings - they in rare cases apepar and disappear based on
earlier compiler decisions, so I don't think it is too bad.

I would expect users to simply compile the code with their default
optimization levels to get result, I just primarily wanted to say that
at -O0 you can't expect to get very good results.

Honza

> annotations for my users (which may use any of the -Ox flags with my
> code), I need to try out all optimization levels in order to find them.
> That does not seem like a decent QoI.  I should have a clear way to find
> out the largest set of functions to annotate, and presumably that would
> be by selecting the highest optimization level and enabling this
> warning/note.
> 
> If I have misunderstood this, then I suggest adjusting the documentation
> to reflect that this scenario cannot happen.
> 
> Thanks,
> Ralf



More information about the Gcc-patches mailing list