Bug 29521 - Confusing warning for return with expression in function returning void
Summary: Confusing warning for return with expression in function returning void
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.2
: P3 enhancement
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2006-10-20 06:16 UTC by Yevgen Muntyan
Modified: 2007-02-13 01:52 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-20 09:09:25


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yevgen Muntyan 2006-10-20 06:16:59 UTC
Consider the following code:

void func () 
{
}

void func2 ()
{
    return func ();
}

gcc -pedantic correctly warns about "return func();", but the warning text is very confusing:
   'return' with a value, in function returning void
It talks about "value" where there is no value involved.
It took me a while to understand what exactly is wrong. Warning says "value", so I obviously checked signatures first; then I looked for a problem with includes; then I asked in comp.lang.c.

It would be better if gcc said something like
   'return' with an expression, in function returning void
or
   ISO C forbids ...

The latter would be the best, I guess.
Comment 1 Richard Biener 2006-10-20 09:09:25 UTC
Confirmed.
Comment 2 patchapp@dberlin.org 2007-01-18 18:05:49 UTC
Subject: Bug number PR 29521

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01533.html
Comment 3 patchapp@dberlin.org 2007-02-12 23:15:29 UTC
Subject: Bug number PR 29521

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01110.html
Comment 4 Manuel López-Ibáñez 2007-02-13 00:29:28 UTC
Subject: Bug 29521

Author: manu
Date: Tue Feb 13 00:29:17 2007
New Revision: 121876

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121876
Log:
2007-02-13  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR c/29521
	* c-typeck.c (c_finish_return): Improve warning message.

testsuite/
	* gcc.dg/c90-return-1.c: Update output.
	* gcc.dg/c99-return-1.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/pr29521-2.c
    trunk/gcc/testsuite/gcc.dg/pr29521.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Manuel López-Ibáñez 2007-02-13 01:52:17 UTC
Fixed in GCC 4.3