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

--- Comment #5 from Alexander Grund <alexander.gr...@tu-dresden.de> ---
So am I right assuming that the following is basically UB as per GCC (although
it should work as per the standard)?

template <class K, class V>
union slot_type {
  map_slot_type() {}
  ~map_slot_type() = delete;
  using value_type = std::pair<const K, V>;
  using mutable_value_type = std::pair<K, V>;

  value_type value;
  mutable_value_type mutable_value;
  K key;
};

--> I.e. given a pointer `slot_type* slot` it _should_ have been possible to
access `slot->value.first`, `slot->mutable_value.first`, `slot->key`
interchangeably but in fact it is not, i.e. not implemented in GCC.

I'm asking because it "may" work, and e.g. seemingly does in GCC 9+, but
yeah... If that is indeed unsupported I'll open a bug report against the repo
using this. Note that this effectively disallows having "flat" maps that return
`std::pair<const K, V>` via their iterators but have support for moving items
effectively (i.e. via `std::pair<const K, V>` pointers)

Reply via email to