https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101061
--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> --- On June 15, 2021 4:21:12 PM GMT+02:00, "alexander.gr...@tu-dresden.de" <gcc-bugzi...@gcc.gnu.org> wrote: >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. That's correct. >I'm asking because it "may" work, and e.g. seemingly does in GCC 9+, Yeah, the circumstances have been so there's incentive to do an invalid transform... >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)