https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111050

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
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 expected
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 function
gets called with a 'this' pointer from GCC 11 code, it will apply the non-zero
offset when it shouldn't (and vice versa).

Reply via email to