Mail Archives: djgpp/1999/10/22/21:31:08
ryot AT bigfoot DOT com (George Ryot) said:
> The way to find out is to simplify the program to the smallest that
> will still exhibit the problem:
>
> /*** bug.c ***/
>
> int main(void)
> {
> return 0;
> }
>
> void qsort(int *v)
> {
> v[30000] = 0;
> }
> ...
>
> The DJGPP startup code calls the globbing function which in turn calls
> qsort which has been redefined to do something bad.
>
> Whether this is a program or compiler bug hinges on whether or not it
> is legal to have user defined functions which overide those in libc.
>
> I am fairly sure that it is, and so this is indeed a DJGPP bug.
No, it not. The linker cannot possibly know that the prototype for
your qsort() is bad. This problem hadn't occured if you've used
'gcc -Wall' and paid attention to the warnings. In which case including
<stdlib.h> would resulted in a compile error.
And it's fully legal to replace libc functions with your own (with correct
args of course).
Gisle V.
- Raw text -