Oct. 26, 2022
4:25 p.m.
Tom Lane via tz said:
Jonathan Leffler via tz <tz@iana.org> writes:
I see nothing in the C standard specification of qsort() that says sorting an array with zero members leads to undefined behaviour.
The C standard is silent on this (at least as of C99), but POSIX is absolutely unambiguous:
If the nel argument has the value zero, the comparison function pointed to by compar shall not be called and no rearrangement shall take place.
But does it say whether the first argument is allowed to be NULL? -- Clive D.W. Feather | If you lie to the compiler, Email: clive@davros.org | it will get its revenge. Web: http://www.davros.org | - Henry Spencer Mobile: +44 7973 377646