This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Enable -Wreturn-type by default ?


On 14/11/2013 12:48, Jonathan Wakely wrote:
> On 14 November 2013 11:31, Dodji Seketeli wrote:
>> 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.
> A return statement with no operand is always wrong, but -Wreturn-type
> also warns about this, which is valid:
>
> int f(int c)
> {
>     if (c)
>        return 0;
>     function_that_never_returns();
> }
>
> The noreturn attribute is not portable, and can't necessarily be added
> to library functions not controlled by the user.
>
> So maybe it makes sense to split -Wreturn-type to separately handle
> "return with no value in function returning non-void" and "control
> reaches end of non-void function".
I wrote a patch for this. I am updating the tests (many of them have now
warnings because of -Wreturn-type).
I updated 410 of them and I am still doing the work. Hopefully, I will
send a patch in the next few days...

For "control reaches end of non-void function", I haven't activated by
default and I called the option -Wfalloff-nonvoid-function
Of course, that is just a proposal! :) Better names are welcome.

Sylvestre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]