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

            Bug ID: 115514
           Summary: Nonconforming reverse_iterator::operator->
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: frankhb1989 at gmail dot com
  Target Milestone: ---

The last comment in LWG 1052 says "the wording in [reverse.iter.elem] (of
P0896R4) for operator-> is equivalent to the PR for LWG 1052"; unfortunately
this is not true. The adopted wording in P0896R4 uses `prev` which returns a
prvalue for the call to `operator->`, while the PR uses an lvalue `tmp` for the
call to `operator->`. Since `->` is no longer concerned in C++20's iterator
requirements, there can be observable differences when the iterator having
overloaded `operator->` with different ref-qualifiers in spite of the
equivalence to the expression formed by `operator*` (for lvalues).

The implementation in libc++ follows the standard wording literally. Actually
the original implementation (https://reviews.llvm.org/D120180) has an explicit
`std::move`, suggesting the difference has been acknowledged. (Another
difference is it only applies the resolution for C++17 onward.)

Reply via email to