Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
6.2.6, 6.4.1
-
None
Description
As detected by Lyx guys (https://www.lyx.org/trac/ticket/12215), we're comparing singular (= default-constructed) std:map const_iterator'ss, which is UB. We seem to be creating them when {{d == nullptr}:
const_iterator begin() const noexcept { return d ? const_iterator(d->m.begin()) : /* here: */ const_iterator() ; }
It's unclear how to solve the issue. One way would be to wrap the std::map::const_iterator in std:aligned_union and placing a marker (0b1 in the LSB, which should never be set in a pointer to a node) for the default-construted state. Basically a compact form of optional<>. How compatible that is with libstdc++ debug STL builds remains to be seen.