Bug 48116 - -Wreturn-type does not work as advertised
Summary: -Wreturn-type does not work as advertised
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: documentation
Depends on:
Blocks:
 
Reported: 2011-03-14 17:08 UTC by Tom Tromey
Modified: 2016-06-08 20:55 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-09-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2011-03-14 17:08:31 UTC
I'm using svn trunk gcc as of today.

-Wreturn-type is documented as:

  [... warn] about a `return' statement with a expression
  in a function whose return-type is `void'.

I tried it with this test case:

void x (void) { }
void y(void) { return x(); }

I expected a warning on the `return', but did not get one:

I used "gcc -Wreturn-type -O2 -c q.c"
Comment 1 Andrew Pinski 2011-03-14 17:18:20 UTC
apinski@apinskidesktop:~$ gcc t.c -W -Wall -pedantic -S
t.c: In function ‘y’:
t.c:2: warning: ISO C forbids ‘return’ with expression, in function returning void
Comment 2 Tom Tromey 2011-03-14 17:20:47 UTC
Thanks, but I think it is still a bug as-is.
I don't see why -pedantic should be required here.
Comment 3 Marek Polacek 2014-09-24 18:03:23 UTC
Mine.
Comment 4 Manuel López-Ibáñez 2014-10-18 10:17:37 UTC
Hi Marek,

Do you have even an unfinished patch? I will add this to the list of EasyHacks.
Comment 5 Marek Polacek 2014-10-18 10:54:58 UTC
(In reply to Manuel López-Ibáñez from comment #4)
> Do you have even an unfinished patch? I will add this to the list of
> EasyHacks.

I have nothing so far, I couldn't get to this one yet.  I'm going to unassign myself for now, maybe I'll get to this one some day.

Feel free to put it on EasyHacks.
Comment 6 Jakub Jelinek 2015-04-22 11:58:56 UTC
GCC 5.1 has been released.
Comment 7 Richard Biener 2015-07-16 09:11:20 UTC
GCC 5.2 is being released, adjusting target milestone to 5.3.
Comment 8 Richard Biener 2015-12-04 10:43:48 UTC
GCC 5.3 is being released, adjusting target milestone.
Comment 9 Manuel López-Ibáñez 2015-12-04 11:31:58 UTC
Only regressions have target milestone.
Comment 10 Marcin Baczyński 2016-06-01 11:57:03 UTC
Proposed patch: https://gcc.gnu.org/ml/gcc-patches/2016-06/msg00032.html
Comment 11 Martin Sebor 2016-06-04 20:51:22 UTC
Author: msebor
Date: Sat Jun  4 20:50:50 2016
New Revision: 237093

URL: https://gcc.gnu.org/viewcvs?rev=237093&root=gcc&view=rev
Log:
PR c/48116 - -Wreturn-type does not work as advertised

gcc/ChangeLog:
2016-06-04  Martin Sebor  <msebor@redhat.com>
	    Marcin Baczyński <marbacz@gmail.com>

	PR c/48116
	* doc/invoke.texi (-Wreturn-type): Mention not warning on return with
	a void expression in a void function.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/invoke.texi
Comment 12 Martin Sebor 2016-06-08 20:55:15 UTC
Fixed in r23709 by correcting the manual
.