Closed foonathan closed 1 week ago
We have a number of issues on difference types. I guess there're also remain issues in <vector>
~, <deque>
,~ and <xstring>
.
CC @hewillk.
Edit: deque
is likely to be fixed in #4049.
The issue occurs with _Copy_memmove
too:
Although I think the contiguous_iterator
's difference type should at least have a width greater than or equal to ptrdiff_t
.
testcase: https://godbolt.org/z/Tqhbs7j9v
Describe the bug
We're having a contiguous iterator whose
difference_type
isint
. STL algorithms then translate it to pointers and back, but doing so they e.g. call the iterator's operator- with astd::ptrdiff_t
, notdifference_type
, like here: https://github.com/microsoft/STL/blob/3c1f3d79ea8db9f20ef0854704e3eb131972a606/stl/inc/xutility#L4944This causes a truncation warning.
Command-line test case
https://godbolt.org/z/YbojbWPMd
Expected behavior
No warning should happen, the implementation should cast to the appropriate difference type before invoking the operator.
STL version