https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109122
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- As requested when creating a bug, please read https://gcc.gnu.org/bugs/ which says to provide the testcase, not a URL to somewhere else. #include <cstdio> #include <ranges> #include <vector> #include <concepts> #include <cstring> namespace rng = std::ranges; struct entity { entity(int nr) : nr_{ nr } {} auto get_nr() -> int { return nr_; } int nr_; }; // inline constexpr auto str_prefix() -> std::string_view { return "realtime"; }; int main() { const std::vector<entity> vec = { 1,2,3}; auto it = rng::find(vec, 2, &entity::get_nr); // auto it = rng::find_if(vec, [](int e){ return e == 2; }, &entity::get_nr); if constexpr (std::same_as<decltype(it), std::vector<entity>::const_iterator>) { printf("Const iterator was chosen!\n"); } else if constexpr (std::same_as<decltype(it), std::vector<entity>::iterator>) { printf("Normal iterator was chosen!\n"); } if (it != vec.end()) { printf("found vec element %d\n", it->nr_); } } 109122.cc: In function 'int main()': 109122.cc:28:24: error: no match for call to '(const std::ranges::__find_fn) (const std::vector<entity>&, int, int (entity::*)())' 28 | auto it = rng::find(vec, 2, &entity::get_nr); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/jwakely/gcc/13/include/c++/13.0.1/tuple:44, from /home/jwakely/gcc/13/include/c++/13.0.1/bits/uses_allocator_args.h:38, from /home/jwakely/gcc/13/include/c++/13.0.1/bits/memory_resource.h:41, from /home/jwakely/gcc/13/include/c++/13.0.1/string:58, from /home/jwakely/gcc/13/include/c++/13.0.1/bits/locale_classes.h:40, from /home/jwakely/gcc/13/include/c++/13.0.1/bits/ios_base.h:41, from /home/jwakely/gcc/13/include/c++/13.0.1/streambuf:43, from /home/jwakely/gcc/13/include/c++/13.0.1/bits/streambuf_iterator.h:35, from /home/jwakely/gcc/13/include/c++/13.0.1/iterator:66, from /home/jwakely/gcc/13/include/c++/13.0.1/ranges:43, from 109122.cc:2: /home/jwakely/gcc/13/include/c++/13.0.1/bits/ranges_util.h:445:7: note: candidate: 'template<class _Iter, class _Sent, class _Tp, class _Proj> requires (input_iterator<_Iter>) && (sentinel_for<_Sent, _Iter>) && (indirect_binary_predicate<std::ranges::equal_to, std::projected<_I1, _P1>, const _Tp*>) constexpr _Iter std::ranges::__find_fn::operator()(_Iter, _Sent, const _Tp&, _Proj) const' 445 | operator()(_Iter __first, _Sent __last, | ^~~~~~~~ /home/jwakely/gcc/13/include/c++/13.0.1/bits/ranges_util.h:445:7: note: template argument deduction/substitution failed: /home/jwakely/gcc/13/include/c++/13.0.1/bits/ranges_util.h:445:7: note: constraints not satisfied In file included from /home/jwakely/gcc/13/include/c++/13.0.1/bits/stl_iterator_base_types.h:71, from /home/jwakely/gcc/13/include/c++/13.0.1/iterator:61: /home/jwakely/gcc/13/include/c++/13.0.1/bits/iterator_concepts.h: In substitution of 'template<class _Iter, class _Sent, class _Tp, class _Proj> requires (input_iterator<_Iter>) && (sentinel_for<_Sent, _Iter>) && (indirect_binary_predicate<std::ranges::equal_to, std::projected<_I1, _P1>, const _Tp*>) constexpr _Iter std::ranges::__find_fn::operator()(_Iter, _Sent, const _Tp&, _Proj) const [with _Iter = std::vector<entity>; _Sent = int; _Tp = int (entity::*)(); _Proj = std::identity]': 109122.cc:28:24: required from here /home/jwakely/gcc/13/include/c++/13.0.1/bits/iterator_concepts.h:634:13: required for the satisfaction of 'input_or_output_iterator<_Iter>' [with _Iter = std::vector<entity, std::allocator<entity> >] /home/jwakely/gcc/13/include/c++/13.0.1/bits/iterator_concepts.h:656:13: required for the satisfaction of 'input_iterator<_Iter>' [with _Iter = std::vector<entity, std::allocator<entity> >] /home/jwakely/gcc/13/include/c++/13.0.1/bits/iterator_concepts.h:635:9: in requirements with '_Iter __i' [with _Iter = std::vector<entity, std::allocator<entity> >] /home/jwakely/gcc/13/include/c++/13.0.1/bits/iterator_concepts.h:635:33: note: the required expression '* __i' is invalid 635 | = requires(_Iter __i) { { *__i } -> __detail::__can_reference; } | ^~~~ cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more detail /home/jwakely/gcc/13/include/c++/13.0.1/bits/ranges_util.h:459:7: note: candidate: 'template<class _Range, class _Tp, class _Proj> requires (input_range<_Range>) && (indirect_binary_predicate<std::ranges::equal_to, std::projected<decltype(std::ranges::__cust_access::__begin((declval<_Container&>)())), _Proj>, const _Tp*>) constexpr std::ranges::borrowed_iterator_t<_Range> std::ranges::__find_fn::operator()(_Range&&, const _Tp&, _Proj) const' 459 | operator()(_Range&& __r, const _Tp& __value, _Proj __proj = {}) const | ^~~~~~~~ /home/jwakely/gcc/13/include/c++/13.0.1/bits/ranges_util.h:459:7: note: template argument deduction/substitution failed: /home/jwakely/gcc/13/include/c++/13.0.1/bits/ranges_util.h:459:7: note: constraints not satisfied 109122.cc: In substitution of 'template<class _Range, class _Tp, class _Proj> requires (input_range<_Range>) && (indirect_binary_predicate<std::ranges::equal_to, std::projected<decltype(std::ranges::__cust_access::__begin((declval<_Container&>)())), _Proj>, const _Tp*>) constexpr std::ranges::borrowed_iterator_t<_Range> std::ranges::__find_fn::operator()(_Range&&, const _Tp&, _Proj) const [with _Range = const std::vector<entity>&; _Tp = int; _Proj = int (entity::*)()]': 109122.cc:28:24: required from here /home/jwakely/gcc/13/include/c++/13.0.1/bits/iterator_concepts.h:533:13: required for the satisfaction of '__indirectly_readable_impl<typename std::remove_cvref<_Tp>::type>' [with _In = std::projected<decltype(std::ranges::__cust_access::__begin((declval<_Container&>)())), _Proj>] /home/jwakely/gcc/13/include/c++/13.0.1/bits/iterator_concepts.h:553:13: required for the satisfaction of 'indirectly_readable<_I1>' [with _I1 = std::projected<decltype(std::ranges::__cust_access::__begin((declval<_Container&>)())), _Proj>] /home/jwakely/gcc/13/include/c++/13.0.1/bits/iterator_concepts.h:736:13: required for the satisfaction of 'indirect_binary_predicate<std::ranges::equal_to, std::projected<decltype (std::ranges::__cust_access::__begin(declval<_Container&>())), _Proj>, const _Tp*>' [with _Range = const std::vector<entity, std::allocator<entity> >&; _Proj = int (entity::*)(); _Tp = int] 109122.cc:28:24: error: template constraint failure for 'template<class _Iter, class _Proj> requires (indirectly_readable<_Iter>) && (indirectly_regular_unary_invocable<_Proj, _Iter>) struct std::projected' 28 | auto it = rng::find(vec, 2, &entity::get_nr); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 109122.cc:28:24: note: constraints not satisfied ' g++: internal compiler error: Segmentation fault signal terminated program cc1plus Please submit a full bug report, with preprocessed source (by using -freport-bug). See <https://gcc.gnu.org/bugs/> for instructions. It segfaults with GCC 12 too, but only for --enable-checking builds.