This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] [FIX PR c/48116] -Wreturn-type does not work as advertised
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Prasad Ghangal <prasad dot ghangal at gmail dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 4 May 2016 16:02:52 +0000
- Subject: Re: [PATCH] [FIX PR c/48116] -Wreturn-type does not work as advertised
- Authentication-results: sourceware.org; auth=none
- References: <CAE+uiWYwGEeAHs7LiTaxyQZgkTdJ7Y1Pvzaf8pVi0WxbBBJv7A at mail dot gmail dot com>
On Mon, 11 Apr 2016, Prasad Ghangal wrote:
> Hi!
>
> This is proposed patch for
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48116 (-Wreturn-type does
> not work as advertised)
I think that this is actually a documentation bug and should be fixed by
changing the documentation, not by changing the code. That is, the patch
<https://gcc.gnu.org/ml/gcc-patches/2007-02/msg01102.html> that added the
assertion about return with a value from functions returning void was
mistaken: if the expression is non-void, the diagnostic is mandatory, and
if it's a void expression, this is a legitimate, long-standing extension
to ISO C, taken from ISO C++, and should be documented as such and not
warned for except with -pedantic. So there should be two documentation
changes: (a) correct the description of -Wreturn-type and (b) explicitly
document return of void expressions from functions returning void as a GNU
C extension taken from ISO C++.
--
Joseph S. Myers
joseph@codesourcery.com