From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 649FF3858C50; Mon, 25 Mar 2024 11:52:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 649FF3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711367569; bh=avAA6e/uPEVkj5f6jo9k9YyZfAJrTYCDlK67VUzOfS8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m7OZhAuEtHF8Fs0a2Jn/CHU4E4HxhTVEIQeZE4X/JagJJmNNK5lmQnqPX56qHyba8 poevW5LLx58I+jG0VSWCGuGG6X/FtRDd1LsdV6X9kViSGpZG9lQBQgd6z449g1kUiN lnusypAuy4w3Ca31F6MXOyjOH1sKxohhkOL302U0= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114462] [C++26] P2809R3 - Trivial infinite loops are not undefined behavior Date: Mon, 25 Mar 2024 11:52:48 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114462 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- I know, but I think this will need changes in the C++ FE. I was asking recently Jason what the "when interpreted as a constant-expression" in the paper actually means, whether such expression should be evaluated as manifestly constant evaluation or not. If yes, it seems like an incompatible change in a DR, because say #include void foo () { while (std::is_constant_evaluated ()) ; } changing behavior from previous doing nothing to an infinite loop. If it is not manifestly constant evaluation, still, the FE would need to (at least for the cases listed in the paper) try to silently constant evaluate = the condition (with mce_false such that std::is_constant_evaluated () is folded to false in the= re; but perhaps only during cp_fold_function?) and if that evaluates to non-zero replace the condition with true, such that the middle-end would then really consider it as infinite loop regardless of -ffinite-loops. Because if one has constexpr bool bar () { return true; } void baz () { while (bar ()) ; } we want middle-end to see while (true) ; rather than while (bar ()) ; becau= se the latter would be under -ffinite-loops decision.=