<algorithm>
: Audit divergence of difference types between wrapped and unwrapped iterators and correct the uses
#5466
Labels
bug
Something isn't working
Describe the bug
Currently, this program, when compiled with MSVC using
-std:c++latest -W3
, triggers warning C4244.There're probably other algorithms incorrectly triggering this warning.
The cause seems to be that MSVC STL generally assumes that a wrapped iterator type has the same difference type as its corresponding unwrapped one. The assumption is incorrect when the wrapped iterator is an iterator type of
basic_string
orvector
or some iterator adapting it. In such a case, the difference type of the wrapped iterator is determined by the iterator, while the difference type of the unwrapped iterator isptrdiff_t
.Command-line test case
https://godbolt.org/z/c99638j69
Expected behavior
No warning C4244 due to small
difference_type
/size_type
of allocator types, for all algorithms.STL version
Probably all existing versions where this program is accepted.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: