From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 721CD385700F; Mon, 22 Mar 2021 09:10:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 721CD385700F From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99677] [[gnu::const]] attribute does not prevent dead global variable gets emitted. Date: Mon, 22 Mar 2021 09:10:38 +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: 11.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 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: Mon, 22 Mar 2021 09:10:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99677 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- As the functions aren't constexpr, they aren't even considered during C++ FE constexpr processing. gnu::const means something completely different. I bet we optimize away static const variables only written (even with non-constant initializers) and never address taken or otherwise used, this = PR seems to ask to handle inline const (with the C++ FE specific behavior for them) in such cases too. I'm not sure it is valid if the vars are odr-used somewhere and the odr-uses are later optimized away, I think emitting the inline vars in that case is = part of the ABI. And the not odr-used cases which are only used by their initialization is yet another question.=