Skip to content

Commit

Permalink
fix call to std::min() with potentially multiple arg types
Browse files Browse the repository at this point in the history
Summary: `std::min` requires both its arguments to have identical types. In this call-site in `folly/algorithm/simd/test/ContainsTest.cpp`, one argument has type `unsigned long` and the other has type `std::size_t` (from `std::vector<T>::size_type`). These two types may be the same on some platforms, in that `size_t` is an alias to `unsigned long` on some platforms, but this is not specified. And this assumption does in practice fail, breaking the build.

Differential Revision: D64643993

fbshipit-source-id: 4559f14c2bb548036c7bab408c61b46380603e8a
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Oct 20, 2024
1 parent a6e3b26 commit f7eb036
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions folly/algorithm/simd/test/ContainsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ TYPED_TEST(ContainsTest, Basic) {

for (std::size_t size = 0; size != 100; ++size) {
std::vector<T> buf(size, T{0});
for (std::size_t offset = 0; offset != std::min(32UL, buf.size());
++offset) {
auto const bound = std::min(std::size_t(32), size);
for (std::size_t offset = 0; offset != bound; ++offset) {
folly::span<T> haystack(buf.data() + offset, buf.data() + buf.size());
T needle{1};
testSimdContainsVerify(haystack, needle, /*expected*/ false);
Expand Down

0 comments on commit f7eb036

Please sign in to comment.