I think there's two issues here. An implementation could modify the call
to qsort. Chris Torek says this about that:
%- That said, I do not know of any C implementations that modify calls
%- to qsort(). Of course, this does not guarantee that none exist.
%- (Among other things, to cross comp.lang.c threads a bit, I have
%- never seen or used a [full] C99 implementation. Perhaps one of
%- those -- several are rumored to exist -- might substitute some
%- qsort() calls, for instance.
I don't understand what "modify calls to qsort()" means.
This was in a side discussion about whether compilers are allowed
to recognize (and modify) calls to "standard library" functions.
We have examples of compilers that *do* this. Under gcc, with
certain invocations, this:
#include <stdio.h>
int main(void) {
printf("hello world\n");
return 0;
}
compiles to code that links with the puts() routine, not the printf()
routine. Clearly there is a call to printf(), but in fact there
is a call to puts(). The compiler has modified the source code,
so that there is no call to printf() in the object code.
Similarly, compilers may "inline" calls to memcpy() (many do),
sqrt() (some do), and so on. So if you, as a C programmer simply
using some implementation(s), attempt to do tricky things "behind
the back" of your implementation -- such as provide your own private
printf() or sqrt() or memcpy() -- you may get ambushed by the
compiler.
The main take-away lesson for the C programmer is, or at least
should be, "when you write a sort routine, do not call it qsort()".
Use some other name, such as "Hoare_QuickSort()" for instance.
Then, even if some fancy compiler recognizes and modifies calls to
qsort() -- just as gcc modifies calls to printf() and memcpy() --
it will not affect *your* code, because you did not use the name
"qsort". (In this respect, K&R, even K&R2, are doing a bit of a
disservice. To be fair, the original book was written during the
"wild west days of C" as it were, when C was whatever Dennis's
compiler did, and even the second edition predated the C standard.
The new standard gave compiler-writers more options than Dennis
had perhaps intended originally.)