[all-commits] [llvm/llvm-project] 3bd71c: [libc++] Fix ambiguous call in {ranges, std}::find...

Peng Liu via All-commits all-commits at lists.llvm.org
Thu Mar 13 11:15:24 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3bd71cbec75292f188bee3aaba2dc94c8955ad66
      https://github.com/llvm/llvm-project/commit/3bd71cbec75292f188bee3aaba2dc94c8955ad66
  Author: Peng Liu <winner245 at hotmail.com>
  Date:   2025-03-13 (Thu, 13 Mar 2025)

  Changed paths:
    M libcxx/include/__algorithm/find.h
    M libcxx/include/__bit/countr.h
    M libcxx/include/__bit_reference
    M libcxx/include/__fwd/bit_reference.h
    M libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
    M libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
    M libcxx/test/std/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp

  Log Message:
  -----------
  [libc++] Fix ambiguous call in {ranges, std}::find (#122641)

This PR fixes an ambiguous call encountered when using the `std::ranges::find` or `std::find`
algorithms with `vector<bool>` with small `allocator_traits::size_type`s, an issue reported
in #122528. The ambiguity arises from integral promotions during the internal bitwise
arithmetic of the `find` algorithms when applied to `vector<bool>` with small integral
`size_type`s. This leads to multiple viable candidates for small integral types:
__libcpp_ctz(unsigned), __libcpp_ctz(unsigned long), and __libcpp_ctz(unsigned long long),
none of which represent a single best viable match, resulting in an ambiguous call error.

To resolve this, we propose invoking an internal function __countr_zero as a dispatcher
that directs the call to the appropriate overload of __libcpp_ctz. Necessary amendments
have also been made to __countr_zero.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list