From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 167B93883032; Thu, 6 Oct 2022 10:46:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 167B93883032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665053179; bh=sqI4PmnmLGoMc234Jjp3z58McYjjTb93ZgzAVhZYnds=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Y3kpM/HkrrH+n2NBwR8b/AFKd9sp4GUuyHcXfj+ekfPUlMyOqN3p0aCMG0oO2quis BJ9dPvIilxSBrw0G3ZyG0/esiQND1diHS9/o9O6J6pYj+qkKV39T+ZHJzwbsroTcuO IcLYiD5QnrktFTKxb0jbc3Kr9TIQg3Vv8QzK5i/A= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107161] gcc doesn't constant fold member if any other member is mutable Date: Thu, 06 Oct 2022 10:46:09 +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.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107161 --- Comment #1 from Richard Biener --- GCC relies on 'p' being in .rodata for the folding which of course cannot be the case with a mutable member. Note the frontend clears the 'const' from = the declaration because of the mutable member and we have no way to distinguish constant from non-constant members here. Do constexpr/consteval work in such circumstances?=