This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/59434] New: move_iterator is broken for input iterators with an rvalue as reference type
- From: "cheparukhin at yandex dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 09 Dec 2013 15:51:51 +0000
- Subject: [Bug libstdc++/59434] New: move_iterator is broken for input iterators with an rvalue as reference type
- Auto-submitted: auto-generated
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.