[comp.lang.c] gcc -Wall fails to catch wrong use of calloc

ajayshah@alhena.usc.edu (Ajay Shah) (05/23/91)

Script started on Tue May 21 09:16:16 1991
[max 4] cat a.c
#include <stdlib.h>
int main()
{
	char *p;
	p = (char *) malloc(100);
	p = (char *) realloc(200);
	return 0;
}
[max 5] gcc -Wall a.c
[max 6] exit
[max 7] 
script done on Tue May 21 09:16:49 1991

-- 
_______________________________________________________________________________
Ajay Shah, (213)734-3930, ajayshah@usc.edu
                             The more things change, the more they stay insane.
_______________________________________________________________________________

richard@aiai.ed.ac.uk (Richard Tobin) (05/23/91)

In article <33084@usc> ajayshah@alhena.usc.edu (Ajay Shah) writes:

>#include <stdlib.h>

>	p = (char *) realloc(200);

... and complains that gcc doesn't produce a warning.

You wouldn't be using a Sun by any chance, would you?  Perhaps a Sun
whose <stdlib.h> contains a line like this:

   extern char *   realloc(/* void *ptr, size_t size */);

Note the commenting out of the arguments.

It's not gcc's fault; just use a real prototype for realloc().

-- Richard
-- 
Richard Tobin,                       JANET: R.Tobin@uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin