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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> Another option would be to drop the base class from std::allocator when
> configured to derive from new_allocator, and just inline that code into
> std::allocator. That's an ABI break, because it would no longer have a base
> class of type __gnu_cxx::new_allocator, but maybe it's one that wouldn't
> cause any problems in practice.

I think we can mitigate the ABI break by giving __gnu_cxx::new_allocator and
std::allocator a common base class, which would still prevent them from being
potentially-overlapping subobjects as is the case today.

Testcase for the current ABI properties:

#include <memory>
#include <ext/new_allocator.h>

struct A : __gnu_cxx::new_allocator<char> { };
struct B : std::allocator<char>, A { };
struct C : std::allocator<char> { A a; };

static_assert( sizeof(B) == 2 );
static_assert( sizeof(C) == 2 );
  • [Bug libstdc++/64135] Allocator... redi at gcc dot gnu.org via Gcc-bugs

Reply via email to