This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] PR55189 enable -Wreturn-type by default
- From: Sylvestre Ledru <sylvestre at debian dot org>
- To: gcc-patches at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>
- Date: Thu, 05 Jun 2014 11:33:21 +0200
- Subject: Re: [Patch] PR55189 enable -Wreturn-type by default
- Authentication-results: sourceware.org; auth=none
- References: <538F7856 dot 1090104 at debian dot org> <Pine dot LNX dot 4 dot 64 dot 1406042321130 dot 2874 at digraph dot polyomino dot org dot uk>
On 05/06/2014 01:31, Joseph S. Myers wrote:
> On Wed, 4 Jun 2014, Sylvestre Ledru wrote:
>
>> Hello,
>>
>> Finally, I have been able to update all tests with -Wreturn-type enabled
>> by default. AFAIK, under GNU/Linux Debian Jessie 64 bits, there is no
>> PASS->FAIL tests.
>>
>> Now, I would like to know if I can commit that into the repository. Who
>> can review that?
>>
>> As attachment, you will find the actual (tiny) patch.
>>
>> I split the tests update by languages. As they are big ( 1260 files
>> changed, 1638 insertions(+), 903 deletions(-) ), I uploaded the patches
>> on my server:
>
> Some of those patches appear to be addressing cases where control appears
> to reach the end of a function returning non-void, as opposed to cases
> where the return type defaults to int.
Do you have an example of the patches you are talking about?
> As I said in
> <https://gcc.gnu.org/ml/gcc/2014-01/msg00207.html>, I don't think that
> warning is appropriate to enable by default as it catches perfectly valid
> C90 / C99 code that avoids using extensions to annotate noreturn
> functions.
I can try to implement that but I don't know where to start. Any clue?
> (I *do* think it's appropriate to enable by default the warning about
> return type defaulting to int - more generally, to enable -Wimplicit-int
> -Wimplicit-function-declaration - and the -Wreturn-type warning about a
> return statement without a value in a function returning non-void also
> seems appropriate to enable by default.
I can try to enable them too by default. It seems my patches are
covering most of the tests updates.
> Warning about the absence of any
> return statement in a function returning non-void is probably also a
> reasonable default warning from the -Wreturn-type set; it's specifically
> the flow-based warnings that can give false positives in the absence of
> noreturn annotations that I'm dubious about enabling by default.)
You are talking about code like this one (from Jonathan Wakely) ?
int f(int c)
{
if (c)
return 0;
function_that_never_returns();
}
Initially, I implemented -Wmissing-return to manage this case (
https://gcc.gnu.org/ml/gcc-patches/2014-01/msg00820.html ) but Jason
suggested to remove that:
https://gcc.gnu.org/ml/gcc-patches/2014-01/msg01033.html
(I don't have a strong opinion on the subject).
Sylvestre