https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96704
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- Right, it's incorrect to assume begin and end return the same type for a range. Use std::common_iterator if you need to turn an iterator and its sentinel into a single type: using CI = std::common_iterator<decltype(r.begin()), decltype(r.end())>; foo(CI(r.begin()), CI(r.end()));