From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CFE6A3858C3A; Tue, 31 Oct 2023 14:23:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFE6A3858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698762189; bh=DRCcKxCt614REB+1v1+8ACYMdkxPVZ/k4LOw7OQqEzo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SDoSmRgUJkd8mo9mMWtH1t1+BDyqG5Q0Ewadn4Qx+Wq8BrYsMzdrhn2sij6Aqq095 ghN/X7gSfXE1CHUcOAqRRIf5lVk7pmVp6r3A4iJwkJcrdOQuBbq6HORXtgjkZ+mIYJ h2mFHDTeY2QenOoPVlp9MwmPAo1n2THbMSXOYfMo= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112296] __builtin_constant_p doesn't propagate through member functions Date: Tue, 31 Oct 2023 14:23:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: documentation, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW 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: assigned_to bug_status 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=3D112296 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|rguenth at gcc dot gnu.org |unassigned at gcc d= ot gnu.org Status|ASSIGNED |NEW CC| |jason at gcc dot gnu.org, | |rguenth at gcc dot gnu.org --- Comment #11 from Richard Biener --- So as for the original description of this bug - it's a feature then (unles= s it gets clarified in another way). Sorry. I agree it's highly unintuitive an= d I would hope we can eventually add diagnostics for __builtin_constant_p with arguments that have side-effects. At least the documentation should be amended. Waiting for C/C++ frontend maintainers to give an ACK, then I'll propose some wording for the documentation. Btw, clang also implements the weird semantics. int g; int bar () { if (!g) abort (); return 1; } int main() { return __builtin_constant_p (bar()); } returns 0 and doesn't abort().=