Optimisation of unused static functions

Dmitry Semyonov Dmitry.Semyonov@oktet.ru
Wed Dec 3 16:45:00 GMT 2003


gcc-3.3.2 for i686-pc-linux-gnu target _keeps_ unused static functions
in object file, and produces warnings like:

probe.c:2: warning: `bar' defined but not used

arm-wince-pe-gcc (GCC) 3.4 20031112 (experimental) for arm-wince-pe
target produces the same warning, but _eliminates_ the dead code.

Options are "-O2 -c -Wall probe.c".

Is it a deliberate change in gcc?
Is there a way to get the old behavior without decreasing optimization
level to O1?

We are using a trick with putting static functions references and
related data into a custom section to collect them inside a contiguous
memory block. So the code of that functions is not really "dead", the
data from that custom section is copied to .rdata section during final
linking, and used at run-time.


More information about the Gcc-help mailing list