public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* egcs 1.1b odd warnings with inline functions
@ 1998-12-03  8:23 Luke Diamand
  1998-12-03 10:17 ` Jeffrey A Law
  0 siblings, 1 reply; 2+ messages in thread
From: Luke Diamand @ 1998-12-03  8:23 UTC (permalink / raw)
  To: egcs-bugs

Hi!

I have some code that generates a warning if the size of a structure is
more than a particular amount.

So, here's the code:

extern void bcopy( char *s, char *d, int len );

inline static void memcpy(char *pDst, char *pSrc, int len)
{
    bcopy( pSrc, pDst, len);
}

typedef struct
{
    int *c[17];
} MYSTRUCT;

extern MYSTRUCT s1;
extern MYSTRUCT s2;

void process()
{
    s1 = s2;
}

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?

Regards!
Luke Diamand
-- 
Virata http://www.virata.com
Cambridge
Tel: +44 1223 566919      Fax: +44 1223 566915


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: egcs 1.1b odd warnings with inline functions
  1998-12-03  8:23 egcs 1.1b odd warnings with inline functions Luke Diamand
@ 1998-12-03 10:17 ` Jeffrey A Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey A Law @ 1998-12-03 10:17 UTC (permalink / raw)
  To: Luke Diamand; +Cc: egcs-bugs

  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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-12-03 10:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-03  8:23 egcs 1.1b odd warnings with inline functions Luke Diamand
1998-12-03 10:17 ` Jeffrey A Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).