https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104443
Bug ID: 104443
Summary: common_iterator<I, S>::operator-> is not correctly
implemented
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: de34 at live dot cn
Target Milestone: ---
When the adapted iterator type I is a pointer type or has operator->,
std::common_iterator<I, S>::operator-> is required to return the iterator by
reference ([common.iter.access]/(5.1), and std::get for std::variant always
returns reference).
However, currently libstdc++'s implementation returns the iterator by value in
these cases, because "return _M_it;" is used and the return type is specified
by decltype(auto). "return (_M_it);" should be used instead.
Currently only libc++ correctly implements both common_iterator<I,
S>::operator-> and iterator_traits<common_iterator<I, S>>::pointer. See
https://gcc.godbolt.org/z/1Tn5cGrhh.