Geoff Clare <[EMAIL PROTECTED]> writes: > Paul Eggert <[EMAIL PROTECTED]> wrote, on 30 Mar 2007: >> >> So I don't see the point of insisting on a guarantee that SSIZE_MAX >> must be the maximum representable ssize_t value. What can a portable >> application do with that guarantee that it couldn't do otherwise? > > It can use SSIZE_MAX for the same kind of things as INT_MAX et al. are > used, e.g. to check that an arithmetic operation will not overflow > before performing it.
That is true regardless of whether SSIZE_MAX is the maximum representable ssize_t value. For example, this code: bool sum_would_overflow (ssize_t a, ssize_t b) { return a < 0 ? b < 0 : SSIZE_MAX - a < b; } works either way. (Not that I expect most programs are this careful!) Portable code cannot attempt to create an ssize_t value greater than SSIZE_MAX (as this leads to undefined behavior), so -- if we're concerned only about portable code -- it doesn't matter whether size_t values greater than SSIZE_MAX exist in the underyling implementation.