https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110884
--- Comment #5 from Paul Eggert <eggert at cs dot ucla.edu> --- (In reply to Andrew Pinski from comment #4) > PTRDIFF_MAX is required to be less than SIZE_MAX and is the max size of an > array because otherwise a-b would be undefined ... That is true for glibc, but it's not guaranteed by the C standard or by POSIX, and coreutils tries to be portable to odd but conforming platforms. In theory size_t can be 32 bits while ptrdiff_t is 64 bits. It's not much trouble to write MIN (PTRDIFF_MAX, SIZE_MAX) in the few places where it matters. C and POSIX also allow arrays with more than PTRDIFF_MAX elements. However, coreutils takes pains to never create such an array, even on the non-glibc platforms that allow them; this avoids the undefined behavior you mentioned.