You could replace this:
assert((unsigned)size <= SIZE_MAX);
by:
#if INT_MAX > SIZE_MAX
assert((unsigned)size <= SIZE_MAX);
#endif
If the #if
condition is false, the assert
condition is always true and the assert
is unnecessary. The (unsigned)
cast is (probably) necessary to avoid a warning about a comparison between signed and unsigned operands.
Warning: I have not tested this. (To fully test it, I'd need access to a system with int
wider than size_t
, and I've never seen such a system.)