This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/42674] [4.4/4.5 Regression] Bogus "no return statement in function returning non-void" warning
- From: "davek at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jan 2010 00:23:55 -0000
- Subject: [Bug middle-end/42674] [4.4/4.5 Regression] Bogus "no return statement in function returning non-void" warning
- References: <bug-42674-14373@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from davek at gcc dot gnu dot org 2010-01-11 00:23 -------
(In reply to comment #1)
> We should probably warn instead "function returning non-void declared with
> attribute noreturn".
>
I think not; I don't see why you should be obliged to change the prototype of a
function in order to tell the compiler that it does not return, and it's very
often the case that you can't control the prototype of a function. The
particular example this came from was a thread function that was spawned by
pthread_create, so it had to have an int return type, even though it had a
while (1) loop that meant it never would, in fact return; I wanted to tell the
compiler that.
Note however that I only included noreturn to show that it doesn't suppress the
warning; the warning arises even without it (as I mentioned in the list thread
but see I forgot to mention earlier here; sorry). The real problem is that it
shouldn't complain about a missing return statement if there's no possible way
of exiting the function.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42674