Oct. 26, 2022
6:59 p.m.
On 2022-10-26 11:55, Garrett Wollman via tz wrote:
In a perhaps less ridiculous case, undefined behavior when such a library function is called with a null pointer for a source argument allows the implementation (especially an inlining compiler) to pre-warm the d-cache before entering the main loop.
Unless I'm misunderstanding your example this sort of optimization cannot be done for qsort, since the base pointer can be valid and non-null but not dereferencable, e.g., qsort has well-defined behavior if the pointer points one past the end of an array and nmemb is zero.