From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A5DA93858D3C; Tue, 12 Sep 2023 16:07:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5DA93858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694534829; bh=WWWNXOdichCJ/dbHQWNonH+/SCoW9vYIl9vj2sfvl0g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PM/AdXYSQXww0U8xXnXBhV9wwAIst020yH38ZBZC797rTpvcKs8hxFoAKBcPAaL5g Slzo7w+5JnRSa5T/9uBW/rucpUROmybKy44YaS4SMQZ4wiH4wMtK6kvOij0poat7Rg bFFpba3LtYIsYY+SV1M0usOjbyKyFOpmzSQGCWIM= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/111050] [11/12/13/14 Regression] ABI break in _Hash_node_value_base since GCC 11 Date: Tue, 12 Sep 2023 16:07:09 +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: 13.0 X-Bugzilla-Keywords: ABI X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: fdumont at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 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=3D111050 --- Comment #11 from Jonathan Wakely --- Right. The _M_valptr() function compiles to something like: return (_Value*)((char*)this + offsetof(_Hash_node_value_base, _M_storage); In GCC 10, the offsetof expression was non-zero, specifically it was sizeof(_Hash_node_base). So the _M_valptr() function emitted by GCC 10 expe= cted to access the storage member at a non-zero offset to the 'this' pointer pointing to the _Hash_node_value_base subobject. In GCC 11+ the offsetof expression is zero, so the definition of _M_valptr() emitted by GCC 11 does something different. That's an ABI break. If the linker chooses the GCC 10 definition of the function, but the functi= on gets called with a 'this' pointer from GCC 11 code, it will apply the non-z= ero offset when it shouldn't (and vice versa).=