[comp.sys.sgi] C compiler bug!

sweetmr@sct60a.sunyct.EDU (michael sweet) (03/29/91)

I seem to have run into a nasty bug in the MIPS C compiler.  When using the
'-prototypes' flag (to use function prototypes), the compiler allows local
variables to override the function's arguments.  A little bit of code to
demonstrate:

TASC_CNY:~/c cat cc_proto.c

#include <stdio.h>

void somefunction(char *string)
{
 int string[500];

 puts(string);
}


void main()
{
 somefunction("Hello World");
}

TASC_CNY:~/c cc -prototypes cc_proto.c -o cc_proto

ccom: Warning: cc_proto.c, line 7: Argument Type Doesn't Match prototype description; prototype: pointer to const unsigned char is different from actual: pointer to int
       puts(string);
      ------------^

TASC_CNY:~/c cc_proto

TASC_CNY:~/c


As you can see from the compiler error, the local array 'string' overrides
the argument 'string'.  This happens whether or not I put the declaration as
a prototype or in the old K&R format.  If I omit the '-prototypes' option,
the compiler doesn't say anything at all!

Is this bug fixed in IRIX 4.0?  In the meantime, I guess I'll just use the
GNU C compiler for development (and watch out for ANSI things that the MIPS
compiler doesn't support yet!)

 -Mike Sweet

------------------------------------------------------------------------------
"The only        TASC                      (315) 724-1100 (voice)
 truth is that   555 French Road           (315) 724-2031 (fax)
 there are no    New Hartford, NY  13413   Internet: sweetmr@sct60a.sunyct.edu
 truths, only beliefs."                    Delphi:   DODGECOLT
------------------------------------------------------------------------------