From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2A3F838582A5; Sun, 18 Sep 2022 12:28:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A3F838582A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663504083; bh=i40/juoWXtwiXFJObur/Y3iHJeQVTa1Ei98x7NY8wH4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qF0AYLyOUQ2OQVb08gNy18voQsI8DmCfNkUPyvWGn3CMtpb/4WXuyGxkxTBS1t6/e IQ2JUlmzA4nBFoDliWDEVLQrnwriys2N0T6V897pIj/9dk4zPJnQdiaAvpAg/Zpnnn mbXds+oz68s0nDwJnjprukBFhDgHyGbkS8tu9k1w= From: "andysem at mail dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/98978] Consider packing _M_Engaged in the tail padding of T in optional<> Date: Sun, 18 Sep 2022 12:27:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: ABI, missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: andysem at mail dot ru 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=3D98978 --- Comment #6 from andysem at mail dot ru --- (In reply to Jonathan Wakely from comment #5) > (In reply to andysem from comment #3) > > Is there no way to improve standard components implementation? I'd imag= ine > > you could provide the new implementation in the new version inline name= space > > and still support the old ABI for backward compatibility. >=20 > To give a more complete answer: Inline namespaces don't help, that's a my= th. >=20 > struct X { std::optional b; }; >=20 > Now one translation unit has X using the old ABI and one has X using the = new > ABI, but they're the same X. The fact that the two versions of optional a= re > in different namespaces is no help at all. You still have an ABI break. >=20 > We did it for std::string and it was a multi-year effort that caused > disruption across the industry. It's not worth doing that again to save a > few bytes in std::optional. You could include a hash of all members' namespaces in the X's mangled name= . Or maybe add an attribute that would propagate a tag to the outer class' mangl= ed name. Yes, that's also an ABI change in itself, but a useful one that would allow inline namespaces to become useful. I think a way to improve standard library components is essential. If not inline namespaces then something else. Otherwise there is no evolution path= of the standard library components.=