https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101587
--- Comment #11 from 康桓瑋 <hewillk at gmail dot com> --- (In reply to Jonathan Wakely from comment #10) > (In reply to 康桓瑋 from comment #9) > > Still need casting the return difference type from __mindist, I think? > > Ah yes, we need to cast it back to the type of the first argument. > > So maybe __mindist isn't actually worth it, and it would be simpler to do: > > if (auto __d = __olast - __ofirst; __d < __n) > __n = static_cast<iter_difference_t<_Iter>>(__d); > Agreed. Or __n = staitc_cast<decltype(__n)>(__d).