FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.

» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian GCC

LinkBack Thread Tools
Old 12-24-2009, 09:31 AM
Richard Kettlewell
Default Bug#526620: closed by Arthur Loiret (reply to aloiret@debian.org) ( Bug#526620: False positive from -Wreturn-type)

reopen 526620

Arthur Loiret wrote:

2009/12/24, Richard Kettlewell <rjk@terraraq.org.uk>:

This function's return type is required to be 'void *' because it is
passed to pthread_create(); but it never actually returns. However,
gcc-4.4 -Wall generates the following warning for it:

playrtp.c: In function ‘queue_thread’:
playrtp.c:327: error: no return statement in function returning non-void

This is expected behavior, your function is not of type void.

It is not expected behavior to anyone who has read the documentation for
the option.

It is expected behavior, as you can see in gcc/c-decl.c:

/* Complain if there's just no return statement. */
if (warn_return_type
&& !current_function_returns_value && !current_function_returns_null
/* Don't complain if we are no-return. */
&& !current_function_returns_abnormally
/* Don't warn for main(). */
&& !MAIN_NAME_P (DECL_NAME (fndecl))
/* Or if they didn't actually specify a return type. */
/* Normally, with -Wreturn-type, flow will complain, but we might
optimize out static functions. */
&& !TREE_PUBLIC (fndecl))
warning (OPT_Wreturn_type,
"no return statement in function returning non-void");
TREE_NO_WARNING (fndecl) = 1;

You can't infer "expected" behavior by reading the source code. That's
what manuals are for.

It's also stupid behavior, as demonstrated by the example of a function
that never returns.

Make your function return the NULL pointer to avoid the warning.

Sorry but this suggestion makes no sense. The function never returns so
suggesting it return a null pointer is meaningless.

Right. Maybe your function just misses a call to pthread_exit (arg) then?

It's not missing anything. The thread does not need to terminate.

Please stop closing this bug report.

Re your earlier question about GCC 4.3, yes there _is_ a difference:

richard@deodand:~$ cat t.c
void *a(void) { for(;; }
static void *b(void) { for(; { } }
richard@deodand:~$ gcc-4.3 -Wall -c t.c
t.c:2: warning: ‘b’ defined but not used
richard@deodand:~$ gcc-4.4 -Wall -c t.c
t.c: In function ‘b’:
t.c:2: warning: no return statement in function returning non-void
t.c: At top level:
t.c:2: warning: ‘b’ defined but not used

i.e. evidently GCC 4.3 was smart enough to spot that the warning didn't
make sense in this kind of case; therefore GCC 4.4 should be able to do
that too.


To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Thread Tools

All times are GMT. The time now is 01:40 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org