egcs 1.1b odd warnings with inline functions
Jeffrey A Law
law@cygnus.com
Thu Dec 3 10:17:00 GMT 1998
In message < 3666B5F2.579BE10E@virata.com >you write:
> If I compile this with egcs 1.1 (egcs-2.91.57a 19980901) with "gcc -S
> -O2 -Wall foo.c" then I get the warning:
> foo.c:4: warning: `memcpy' defined but not used
>
> If I reduce the size of the array in MYSTRUCT to 16, I get no warnings.
> If I use gcc 2.7.2 or egcs 1.0.3 I get no warnings. If I remove the
> struct assignment, I get no warnings. If I remove the declaration of
> memcpy, I get no warnings.
>
> What gives? Should I just put __attribute__ ((unused)) in front of my
> function?
GCC knows how to inline both memcpy and strcpy when it is profitable to do
so. When it is not profitable to do so, it knows how to call into the system
memcpy/bcopy.
You get the unused warning when gcc decides to open code the memcpy/bcopy
instead of perfoming a function call.
My recommendation -- remove your memcpy routine, it's not needed and just
gets in the way.
jeff
More information about the Gcc-bugs
mailing list