Bug in 4.2BSD C compiler...

J. Shapiro jss at sjuvax.UUCP
Thu May 9 07:42:51 AEST 1985


About two days ago I posted an article complaining that the following compiled
incorrectly under 4.2:

int usr1(), usr2(), usr3();

int procs[] = { usr1, usr2, usr3 }

Of course it doesn't compile, but I mistyped what I wanted. Several
people sent suggestions, and my thanks to all of them.  The piece of code
which doesn't compile and should is as follows:

---- correctly typed version ----

int usr1(), usr2(), usr3();

int *procs[] = { usr1, usr2, usr3 };

---------------------------------

Now, several people observed that

int (*procs[])() = ...

will work, and this is correct.  The question arises on the basis of K&R
pp 114-115, which would seem to indicate that my declaration is acceptable
on the grounds that pointers to integers and pointers to functions returning
integers are supposed to be equationally indistinguishable.

Would someone be good enough to try this on System V and tell me if the silly
thing typed correctly compiles?

I don't want to make this a religious battle - I will use what works, but it
did strike me as curious that three of the four C compilers I use regularly
take this without complaint, and that the loser was 4.2BSD. Is this version
right or wrong?

Thanks....



More information about the Comp.lang.c mailing list