This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Symbols which were not used, still in binary
- From: Brian Dessent <brian at dessent dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 28 Jun 2006 13:17:26 -0700
- Subject: Re: Symbols which were not used, still in binary
- References: <44A2DF65.8010704@web.de>
- Reply-to: gcc-help at gcc dot gnu dot org
Steve Kreyer wrote:
> I have compiled the follwing code with the command ''gcc file.c''
>
> ...
>
> Neither is it used in this piece of code, nor is it compiled into an
> object file,
> so in my opinion it should be optimized away by gcc.
> So perhaps anybody can tell me whats wrong with my thought...
First of all, if you just type "gcc file.c" then you have not enabled
any optimization at all. You have to supply -O2 (or -Os, -O1, etc.) if
you want the compiler to perform optimization, as the default is -O0.
That aside, the function won't be eliminated until it's declared
"static", as some other module could still call it.
Brian