[PATCH] libstdc++: Fix iterator caching inside range adaptors [PR100479]

Tim Song t.canens.cpp@gmail.com
Mon May 17 18:39:51 GMT 2021


On Mon, May 17, 2021 at 11:46 AM Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>         constexpr void
>         _M_set(const _Range&, const iterator_t<_Range>& __it)
>         {
>           __glibcxx_assert(!_M_has_value());
> -         _M_iter = __it;
> +         this->_M_payload._M_payload._M_value = __it;
> +         this->_M_payload._M_engaged = true;
>         }
>        };

This part looks questionable - if we don't have a value then we can't
assign to a nonexistent object.

Also, I believe the offset partial specialization of _CachedPosition
needs a change to invalidate the source on move.


More information about the Libstdc++ mailing list