[comp.lang.c] HORRIBLE bug in ultrix 3.1 cc

tbray@watsol.waterloo.edu (Tim Bray) (10/22/90)

Briefly phrased, having two declarations for one external function, one
prototyped, the other not, seems to send cc into an LSD flashback.  Now maybe
you guys out there would NEVER end up including 2 declarations of malloc
in a source file, but it can happen...

By the way, I checked, and this is *not* in mips cc, which has the
decency to throw it out (a wonky error message, but hey...).  This one
has just cost me a whole weekend's work, so I'm in a bitter mood.  Take
the following.  Put it in ccbug.c.

First do:

cc -DBAD ccbug.c
...nasty...

Then do:
cc -DWORSE -o ccbug ccbug.c
./ccbug
...really seriously nasty...

Cheers, Tim Bray, Open Text Systems, Waterloo, Ont.

----Cut here-----------------------------------
#if defined(BAD) || defined(WORSE)
extern char * malloc();
extern char * malloc(unsigned int size);
#endif

#ifdef BAD
int foo(int *, int, int, int, int, int *);
#endif BAD

int
foo(a1, a2, a3, a4, a5, a6)
  int * a1;
  int   a2;
  int   a3;
  int   a4;
  int   a5;
  int * a6;
{
  printf("args: %d %d %d %d %d %d\n", a1, a2, a3, a4, a5, a6);
}

main()
{
  foo((int *) 100, 200, 300, 400, 500, (int *) 600);
}