From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6077E3858C60; Thu, 3 Nov 2022 11:52:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6077E3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667476332; bh=C8qnQKaMCj/yqMDzHQbaf84nnq40ubrLoqqYBaKEs0M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aknIXZPxlolYBYXNNzEOV3gyIYb2p0Y0cxtHZA5H6FAJGLwOPB+k9UJB7ZGuWrLc8 sLizGdbsVhhaDvccnRCxoVI4IjtKq8yDjLWTiBsoBz7hWooxRqPUETtQmukurVZcD0 rGSVOJW3Tf1/W+vn6tjkTGrX5YJd2uyjd8pgan4Y= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107500] Useless atexit entry for ~constant_init in eh_globals.cc Date: Thu, 03 Nov 2022 11:52:10 +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: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE 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=3D107500 --- Comment #17 from Jonathan Wakely --- (In reply to R. Diez from comment #16) > Therefore, variable "static __cxa_eh_globals eh_globals" in the past was > already initialised before any users (probably because static memory being > zeroed on start-up). The situation has not changed now. Now it's enforced by the compiler and will fail to compile if for some reas= on it can't be statically initialized. > This static variable already outlived anything else, as there was no > destructor changing anything on termination. Semantically, no, that's wrong. The C++ standard still says its lifetime en= ds, and the compiler can optimize based on that. It's storage is not reused, but its lifetime does end. But it also says the lifetime of the wrapper ends, so accessing eh_globals.= obj is still semantically undefined. > Your patch introduced wrapper "struct constant_init" around it, which mak= es > GCC generate a constructor for the wrapper solely to register an empty > destructor with atexit(). Otherwise, the wrapper does nothing else useful. >=20 > Your patch also changes '__eh_globals_init::_M_init' (a different global > object) to a static member. Is that not enough to fix the original proble= m? Yes, probably.=