[comp.sys.dec] bug in ds3100 cc?

johns@calvin.EE.CORNELL.EDU (John Sahr) (09/22/89)

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--

cks@white.toronto.edu (Chris Siebenmann) (09/23/89)

 "Losing" variables declared void * appears to be a problem generic to
pcc-derived compilers; if you try it with Ultrix /bin/cc, you will get
the same error message. Right now, the only solution I know of is to
compile with "-Dvoid=int"; you could also try bringing gcc up on the
DS3100.

-- 
	"I shall clasp my hands together and bow to the corners of the world."
			Number Ten Ox, "Bridge of Birds"
Chris Siebenmann		...!utgpu!{ncrcan,ontmoh!moore}!ziebmef!cks
cks@white.toronto.edu	     or ...!utgpu!{,csri!}cks

rogerk@mips.COM (Roger B.A. Klorese) (09/23/89)

In article <1333@calvin.EE.CORNELL.EDU> johns@calvin.spp.cornell.edu.UUCP (John Sahr) writes:
>Does this all mean that the 
>"MIPS cc does not know about `void *' as `anonymous ptr'?"

That's precisely what it means.  Our release 2.10, coming early next year on
our systems and I-don't-know-when from our licensees, will handle this.
-- 
ROGER B.A. KLORESE      MIPS Computer Systems, Inc.      phone: +1 408 720-2939
928 E. Arques Ave.  Sunnyvale, CA  94086                        rogerk@mips.COM
{ames,decwrl,pyramid}!mips!rogerk
"I want to live where it's always Saturday."  -- Guadalcanal Diary