[Bug libstdc++/59434] New: move_iterator is broken for input iterators with an rvalue as reference type
cheparukhin at yandex dot ru
gcc-bugzilla@gcc.gnu.org
Mon Dec 9 15:51:00 GMT 2013
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.
More information about the Gcc-bugs
mailing list