public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Switch coverage
@ 1997-12-31  4:19 Martin von Loewis
  0 siblings, 0 replies; only message in thread
From: Martin von Loewis @ 1997-12-31  4:19 UTC (permalink / raw)
  To: egcs

I noticed that egcs 971225 creates new error messages:

extern inline void * __constant_memcpy(void * to, const void * from, unsigned int n)
{
	switch (n % 4) {
		case 0: return to;
		case 1: return to;
		case 2: return to;
		case 3: return to;
	}
}

mira% gcc -V egcs-2.90.21 -Wall -O2 -c warn.c
mira% gcc -V egcs-2.91.03 -Wall -O2 -c warn.c
warn.c: In function `__constant_memcpy':
warn.c:9: warning: control reaches end of non-void function

Why was this change introduced? I believe neither version was able
to detect that, for all possible values of n, control does *not*
reach end of the non-void function. So the warning is wrong, although
I can see cases where it is useful.

The older gcc versions would report the warning only if the function
was not inline. There is some value to that approach: when it is
inlined, gcc could still try to detect whether there is no result
returned. In case of this function, it would detect that there is
no problem to complain about (as n is known at compile time for
each invocation).

This code is from the Linux kernel. It would be easy to remove
the warning by adding an addition 'return to;' in the end, but
people usually hesitate introducing extra code just to avoid
bogus gcc warnings.

Regards,
Martin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-12-31  4:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-31  4:19 Switch coverage Martin von Loewis

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).