https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64504

--- Comment #2 from Andrey Vihrov <andrey.vihrov at gmail dot com> ---
Thanks for a fast reply!

My use case for these two (amongst several others) options together is
competitive programming, in which a contestant is required a write a
one-source-file solution, test it locally and submit it to a grading server.
Debug Mode helps detect mistakes, and -fwhole-program helps find variables or
functions that I defined and intended to use, but forgot to. For example, for
this source:

int unused;

int main()
{

}

"g++ -Wall -fwhole-program x.cpp" gives

x.cpp:1:5: warning: 'unused' defined but not used [-Wunused-variable]

, and there is no warning without -fwhole-program. Of course, I can get the
same effect by making everything "static", but this depends on me remembering
to do it, so this option is better in this regard. -flto doesn't have the same
effect.

If -fwhole-program isn't supported in this case, then it's fair enough. But
then it would be great if the documentation on -fwhole-program was updated to
clarify when the option can be used and when not.

Reply via email to