https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101587
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> --- (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); I think the integer-class type requirements guarantee we can do __d < __n directly, without explicit conversions. Only the assignment to __n needs an explicit conversion.