From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 00A193973000; Thu, 20 May 2021 17:58:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00A193973000 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100700] -Wreturn-type has many false positives Date: Thu, 20 May 2021 17:58:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: msebor at gcc dot gnu.org 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: cc bug_severity Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2021 17:58:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100700 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Severity|normal |enhancement --- Comment #1 from Martin Sebor --- [Please include the full command line and the full compiler output in bug reports (as requested in https://gcc.gnu.org/bugs/#need). Links to third pa= rty sites are not a substitute (they can go away and the compiler versions they= use can change).] $ cat pr100700.c && gcc -S -xc++ pr100700.c int f(unsigned i) { if (i < unsigned(-1)) return i; } enum E { A, B }; int h (enum E e) { switch (e) { case A: return 0; case B: return 0; } } pr100700.c: In function =E2=80=98int f(unsigned int)=E2=80=99: pr100700.c:4:1: warning: control reaches end of non-void function [-Wreturn-type] 4 | } | ^ pr100700.c: In function =E2=80=98int h(E)=E2=80=99: pr100700.c:13:1: warning: control reaches end of non-void function [-Wreturn-type] 13 | } | ^ In both examples the warning is strictly correct: in a call to f(-1) the function falls off the end, and ditto in a call to h ((enum E)2). I could = see value in relaxing the warning for the enum case and issuing it only under s= ome stricter setting (say with -Wextra or under a new level), similarly to -Wswitch-default. I think there already is a request along these lines.=