Subject: bug in IRIX 4 C compiler

From: "Simon Kilvington" <[email-masked]>
Date: Mon, 30 Oct 1995 13:37:43 +0000 (GMT)

hello,

	this is probably not the right place to post this - so, sorry in
advance. 

	anyway, onto the problem - it's not serious - the correct code is
generated - but you get a warning message cuz the compiler gets confused
about function argument types.

	the shortest program to demonstrate it is...

/* bug.c */

char proc1(char);
char proc2(char);

void
warning(int choice)
{
   char (*proc)(char);

   proc = (choice) ? proc1 : proc2;
}

	when you compile it "cc -c bug.c" the following warnings are
generated...

accom: Warning 294: bug.c, line 11: Function has prototyped and
non-prototyped declarations.  Default promotion of non-prototype form of
argument 1 does not match prototype: prototype: char is different from
actual: int
          proc = (choice) ? proc1 : proc2;
       ----------------------------------^
accom: Warning 196: bug.c, line 11: function prototypes are not
equivalent; function pointer assignment invalid
          proc = (choice) ? proc1 : proc2;
       ----------------------------------^

	for some reason it thinks the last argument to "proc1" and
"proc2" should be an int. 

	if you write...

if(choice)
   proc = proc1;
else
   proc = proc2;

	instead, all is well.

	the compilers with IRIX 5 and IRIX 6 don't have this trouble,
and as I said before, the correct code is generated - so it's more
annoying rather than anything else. 

---
Simon Kilvington, [email-masked]