Created on 2009-09-13.00:00:00 last changed 161 months ago
Proposed resolution:
Change [alg.move], p6:
template<class BidirectionalIterator1, class BidirectionalIterator2> BidirectionalIterator2 move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result);...
Requires: result shall not be in the range
[(first,last]).
Change [alg.copy], p13:
template<class BidirectionalIterator1, class BidirectionalIterator2> BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result);...
Requires: result shall not be in the range
[(first,last]).
[ 2010 Pittsburgh: Moved to Ready. ]
[alg.move], p6 says:
template<class BidirectionalIterator1, class BidirectionalIterator2> BidirectionalIterator2 move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result);...
Requires: result shall not be in the range [first,last).
This is essentially an "off-by-one" error.
When result == last, which is allowed by this specification, then the range [first, last) is being move assigned into the range [first, last). The move (forward) algorithm doesn't allow self move assignment, and neither should move_backward. So last should be included in the range which result can not be in.
Conversely, when result == first, which is not allowed by this specification, then the range [first, last) is being move assigned into the range [first - (last-first), first). I.e. into a non-overlapping range. Therefore first should not be included in the range which result can not be in.
The same argument applies to copy_backward though copy assigning elements to themselves (result == last) should be harmless (though is disallowed by copy).
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
2010-10-21 19:00:35 | admin | set | status: ready -> wp |
2010-10-21 18:28:33 | admin | set | messages: + msg1147 |
2010-10-21 18:28:33 | admin | set | messages: + msg1146 |
2009-09-13 00:00:00 | admin | create |