From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1ECDE385840C; Wed, 12 Jan 2022 19:42:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1ECDE385840C From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103991] [12 Regression] Bogus -Wreturn-type with constexpr if and local var with destructor Date: Wed, 12 Jan 2022 19:42:46 +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: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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: Wed, 12 Jan 2022 19:42:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103991 --- Comment #7 from rguenther at suse dot de --- > Am 12.01.2022 um 17:33 schrieb jakub at gcc dot gnu.org : >=20 > =EF=BB=BFhttps://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103991 >=20 > Jakub Jelinek changed: >=20 > What |Removed |Added > -------------------------------------------------------------------------= --- > CC| |rguenth at gcc dot gnu.org >=20 > --- Comment #4 from Jakub Jelinek --- > For IF_STMT_CONSTEXPR_P and IF_STMT_CONSTEVAL_P IF_STMTs, it is unclear w= hat we > should do, because in either case we throw away the other branch if any. > Either we do for those what we used to do before r12-5638 and risk > -Wunreachable-code warnings (when/if it is readded), e.g. on code like: > if constexpr (true) > return 0; > some code; > but we don't emit these -Wreturn-type false positives in cases where the > untaken block of code doesn't fall through. > Or the r12-5638 can result in such false positives. > Or perhaps we should track if we had the other block of code at all (if n= ot, it > is ok to do what we do right now) and if possible otherwise try to figure= out > if the other block could fall through and if it can't, perhaps replace the > void_node with __builtin_unreachable () call? > For IF_STMT_CONSTEVAL_P we still have the other branch around and could p= erhaps > call block_may_fallthru on it, but for IF_STMT_CONSTEXPR_P we discard it > earlier, > outside of templates already during parsing. >=20 > Now, as Richi's warning isn't in GCC 12, quickest/safest temporary fix wo= uld be > to revert to previous behavior for IF_STMT_CONSTEXPR_P and IF_STMT_CONSTE= VAL_P, > if (IF_STMT_CONSTEVAL_P (stmt)) > stmt =3D else_; > else if (IF_STMT_CONSTEXPR_P (stmt)) > stmt =3D integer_nonzerop (cond) ? then_ ? else_; > else > stmt =3D build3 (COND_EXPR, void_type_node, cond, then_, else_); I agree that reverting for GCC 12 is the most reasonable thing with adding a Testcase > Jason, thoughts on this? >=20 > --=20 > You are receiving this mail because: > You are on the CC list for the bug.=