From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EAF333987C0F; Thu, 20 May 2021 20:20:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAF333987C0F From: "redi 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 20:20:28 +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: redi 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: 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 20:20:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100700 --- Comment #3 from Jonathan Wakely --- (In reply to gnzlbg from comment #2) > Until C++17, creating an enum value that's out-of-range of the enum was > unspecified behavior. In C++ standard >=3D 17 (e.g. -std=3Dc++17), this b= ecame > undefined behavior.=20 With GCC it depends on the -fstrict-enums option. > The only way in which "h(E e)" can fall of its end in C++>=3D17 is if the > program already had undefined behavior. That's true if you use -fstrict-enums, and if you do that, there's no warni= ng. Without that option GCC does not treat (E)2 as undefined, and so it conside= rs it possible for the function to be called with that value.=