From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1EE573858C52; Fri, 20 Jan 2023 07:08:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EE573858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674198481; bh=Hk6Qb8F4c0A4UUx2VCXvMAXuN3bzoo6mKNqH83n1aRc=; h=From:To:Subject:Date:From; b=DFktr5UYsDDYdrKw0H25oBnCEQMskdcJ8RYGwcTJlK+E+BGjiNeuQGqcsAV9bwjyc ocUhMc2KgbGQjyhVmNvNOkv1dd/Z0ACsxVb68jqRgRpw/crP2aTknNpxxrlR5oJyug y8+DcH6G0h+6fwIypFEmdAUyM4rDFYskQMRCmy5w= From: "alexhenrie24 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108476] New: Please turn -Wreturn-type on by default for C Date: Fri, 20 Jan 2023 07:08:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alexhenrie24 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108476 Bug ID: 108476 Summary: Please turn -Wreturn-type on by default for C Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: alexhenrie24 at gmail dot com Target Milestone: --- According to the documentation, -Wreturn-type does the following: "Warn whenever a function is defined with a return type that defaults to int. Also warn about any return statement with no return value in a function whose return type is not void (falling off the end of the function body is considered returning without a value)." https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html I feel strongly that gcc should turn on -Wreturn-type by default for the following reasons: * Not specifying the return value of a function that returns a non-void val= ue is almost always a bug. * C99 and later do not allow declaring or defining a function without a ret= urn type, so there's a good chance that code that omits the return type will br= eak when used with other compilers. * GCC already turns the warning on by default for C++, and all but the most educated of users do not expect C and C++ to be different in this regard, s= o it gives a false sense of security when no such warnings appear when compiling= C code. * Clang already turns the warning on by default for both C and C++, which g= oes to show that the warning does not come up much in practice. I've personally been bitten by forgetting to return a value from a function= , so I hope you will agree that -Wreturn-type is a sensible default to help spot bugs sooner.=