<algorithm>
: find()
/count()
(classic/ranges
) regression finding -1
in unsigned int
elements
#3244
Labels
<algorithm>
: find()
/count()
(classic/ranges
) regression finding -1
in unsigned int
elements
#3244
Reported as DevCom-10206822 and internal VSO-1684032 / AB#1684032 .
This regressed between VS 2022 17.2 and 17.3; I believe it was caused by #2434 adding vectorized implementations of
find()
,count()
,ranges::find()
, andranges::count()
. Compiler Explorer example: https://godbolt.org/z/evhb7fhnbOur test coverage tried to be comprehensive but clearly missed this scenario. We have tests to verify that searching for an
int -1
in a range ofunsigned char
won't find anything, not even theunsigned char 255
, becauseunsigned char == int
promotes theunsigned char
toint
. (The comparison will always befalse
, so we can avoid inspecting the sequence entirely. Indeed, we have to, because callingmemchr()
would produce an incorrect result.)STL/tests/std/tests/Dev11_0316853_find_memchr_optimization/test.cpp
Lines 277 to 296 in e28f956
We also tried to test the limits for all permutations of element types and value types:
STL/tests/std/tests/Dev11_0316853_find_memchr_optimization/test.cpp
Lines 43 to 121 in e28f956
However, in this scenario, we're trying to find an
int -1
in a range containingunsigned int 0xFFFFFFFFu
. Such a comparison should returntrue
(because theint
will be converted tounsigned int
). As @CaseyCarter investigated this, he found that the newly generalized_Within_limits
is reporting that the comparison will never returntrue
.The text was updated successfully, but these errors were encountered: