This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/59434] New: move_iterator is broken for input iterators with an rvalue as reference type


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59434

            Bug ID: 59434
           Summary: move_iterator is broken for input iterators with an
                    rvalue as reference type
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cheparukhin at yandex dot ru

move_iterator<Iterator> is correct only for iterators which satisfy forward
iterator requirements in the part that requires Iterator::reference to be the
same as Iterator::value_type.

If the reference type is an rvalue, i.e. a special proxy object implicitly
convertible to value_type (as in vector<bool>), move_iterator::operator*
returns a dangling reference to a local variable, which causes a segmentation
fault (although this doesn't happen with vector<bool> for some reason, but
happens with more complex value_types).

This is because move_iterator<Iterator>::operator* returns
Iterator::value_type&&. I suggest it should return
remove_reference<Iterator::reference>::type&& instead, it seems that in this
case the problem should be solved.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]