bug in ds3100 cc?

John Sahr johns at calvin.EE.CORNELL.EDU
Sat Sep 23 02:43:01 AEST 1989


I have run across a bug in the MIPS cc C compiler (or in my understanding).
Consider the following.

#include <stdio.h>

int test(void *b)
{
  printf("%d\n", *((int *) b));
  return 0;
}

int main()
{
  int four = 4;
  
  return test((void *) &four);
}

On a microvax (2000, ultrix)  vcc and gcc (1.34) compile this and the result
runs fine. vax cc objects, though (not surprising to me).
On a DS3100, cc objects to the printf("%d\n", *((int *) b)), saying that
b is undefined.  Putting a prototype before test() does not help, and making

typedef void *anonymous;

to replace the void * doesn't help either.  Any comments?  The MIPS cc 
seems to handle the new style declarations pretty well, except for this.

int test(b)
void *b;
{ .... }

Neither uvax lint nor MIPS lint approve of this declaration "b may be used
before set..." among other things.  Does this all mean that the 
"MIPS cc does not know about `void *' as `anonymous ptr'?"

-john

-- 
John Sahr,     Dept. of Electrical Eng., Cornell University, Ithaca, NY 14853
johns@{alfven,calvin}.ee.cornell.edu,  {rochester,cmcl2}!cornell!calvin!johns
--When the dust settles, each B2 bomber will fund NSF for more than a year--



More information about the Comp.sys.sgi mailing list