Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!haven!mimsy!midway!news From: langer@rainbow.uchicago.edu (Steve langer) Newsgroups: comp.sys.sgi Subject: Another C bug? Keywords: C, MIPS, bug, void Message-ID: <1990Jul26.200143.1625@midway.uchicago.edu> Date: 26 Jul 90 20:01:43 GMT Sender: Steve Langer Organization: Research Institutes, University of Chicago Lines: 41 I've been having trouble with the MIPS C compiler on a Silicon Graphics 4D/220 (3.2). I think this is slightly different than the (void *) bug that was discussed here recently. The problem is that pointers to functions returning void aren't treated properly. The following program doesn't compile if TYPE is defined to be "void". It works if TYPE is defined to be "int". It compiles (and works!) in both cases on a Sun. #include #define TYPE void TYPE func() { /* A function */ printf("funk!\n"); } main() { TYPE (*function)(); /* A Pointer to a function */ int test = 1; function = func; if(func == function) (*function)(); /* This line doesn't compile! */ } Here's what the compiler says: rainbow74 >> cc junk.c ccom: Error: junk.c, line 13: operands of == have incompatible types if(func == function) (*function)(); ----------------------^ I get the same thing if I try to use something like void (*f)(), (*g)(); int flag; anotherfunction(flag ? f : g); /* incompatible types for ":" ???? */ Thanks for any advice. Steve (langer@control.uchicago.edu)