Date: Sat, 23 Oct 1999 02:18:10 +0100 (MET) From: Gisle Vanem To: djgpp AT delorie DOT com Subject: Re: a K-R program doesn't work only with DJGPP Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com 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 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.