GCC 4.5 -Wall warns if your function has a non-void return type but returns. It can also detect an infinite loop which means that "falling off the end" doesn't actually imply a return, and therefore suppress the warning in that case.
However, if the function is static, this infinite loop detection does not work: rich...@deodand:~$ cat t.c void *a(void) { for(;;); } static void *b(void) { for(;;) { } } void foo(void) { b(); } rich...@deodand:~$ /usr/local/gcc-4.5.0/bin/gcc -c -Wall t.c t.c: In function b: t.c:2:1: warning: no return statement in function returning non-void This real case where I spotted it was a thread function which is forced to have a return type of 'void *' by the signature of pthread_create(), but never returns because (by design) the thread never terminates. (I assume that the infinite loop detection isn't perfect, but obviously it shouldn't depend on the linkage of the containing function.) rich...@deodand:~$ /usr/local/gcc-4.5.0/bin/gcc --version gcc (GCC) 4.5.0 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Configured with: rich...@deodand:~$ ../configure -C --prefix=/usr/local/gcc-4.5.0 --enable-languages=c,c++ rich...@deodand:~$ uname -a Linux deodand 2.6.32-5-686-bigmem #1 SMP Tue Jun 1 05:38:08 UTC 2010 i686 GNU/Linux rich...@deodand:~$ dpkg -l libc6 ii libc6 2.11.1-3 Embedded GNU C Library: Shared libraries -- Summary: Misdetects missing return with non-void return type, but only if the function is static Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: richard+gcc at sfere dot greenend dot org dot uk http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44511