From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 881513858D35; Wed, 2 Nov 2022 13:04:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 881513858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667394291; bh=SkNoM8MEEgm4pQttx54N+ZALhuY3HvYO5vy98w1s7qM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LMmSsnjfO2AOXRQ5xsuHIUSVs0CIP4+DrQlH1xXDPL8vKnpB0gDobZ//yXb9qVUtB 5Ad5HB3LjG5IZ6L+nSrYcoe9b4NlT61NmCUAyyWcyqsHH8/nVzjifisJQ5fZ1buKZK WH6Ci5fNfU2hRf/ZBWTXGpY2LwMdJ+NNyJGQ7lm8= 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: Wed, 02 Nov 2022 13:04:51 +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: 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: 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 #6 from Jonathan Wakely --- You can't use placement new in a constexpr constructor, so it can't be constinit, which means it is susceptible to the static initialization order fiasco. init priority attributes are also a hack, and less portable. The whole point of this is to ensure the global is accessible *before* any = user code runs, and still accessible *after* static destructors run. Saving a few bytes is less important than correctness. If you really need to avoid it, you can provide a dummy atexit that doesn't register the destructor, or wait for a possible compiler improvement to optimize it away. I'm not going to change libstdc++ to stop doing this.=