This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Enable -Wreturn-type by default ?
- From: Dodji Seketeli <dodji at seketeli dot org>
- To: Sylvestre Ledru <sylvestre at debian dot org>
- Cc: gcc at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Thu, 14 Nov 2013 12:31:25 +0100
- Subject: Re: Enable -Wreturn-type by default ?
- Authentication-results: sourceware.org; auth=none
- References: <5283ABF2 dot 5010209 at debian dot org>
Sylvestre Ledru <sylvestre@debian.org> a Ãcrit:
> I would like to propose the activation by default of -Wreturn-type.
>
> The main objective would to provide a warning for such code:
>
> int foo() {
> return;
> }
>
> For now, it is only enabled when we have -Wall:
> $ gcc -c foo.c
> $ gcc -Wall -c foo.c
> foo.c: In function âfooâ:
> foo.c:2:2: warning: âreturnâ with no value, in function returning
> non-void [-Wreturn-type]
I am wondering why this warning hasn't been activated by default in the
first place, for C++ at least?
Note that using g++ to compile the example above with -std=c++98 yields:
foo.c:2:2: error: return-statement with no value, in function returning âintâ [-fpermissive]
So what do we gain from not emitting that warning by default there?
For C, I am not sure about, but I'd find it useful to have that warning
enabled there too, so I guess I'd like to hear why the warning wasn't
enabled there by default there as well.
Cheers.
--
Dodji