4.2 C bugs?

Ron Natalie <ron> ron at brl-tgr.ARPA
Thu Mar 7 02:55:46 AEST 1985


> >    1)  The C compiler (4.2bsd) barfs on the following:
> > 	void foo() {...}
> > 	void blort() {...}
> > 	void (*f[]) () = {
> > 		foo,			/* Operands of = have incompat. types*/
> > 		blort,			/* Ditto. */
> > 		0
> > 	}
> 
> It's true.  f /* array of pointers */ cannot be initialized to functions.
> In the other cases originally cited, integers could be initialized to
> pointers, but the conversion is implementation-dependent.
> 
> If you want to initialize pointers to pointers, try:
> 
> 	void foo() {...}
> 	void blort() {...}
> 	void (*f[]) () = {
> 		&foo,
> 		&blort,
> 		0
> 	}
> 
WRONG, foo and blort are correctly the address of the function.
His example should work, and does if you are using the system V
compiler.  The 4.2 BSD compiler has a bug that causes makes it
imposible to properly declare pointer to functions returning
void.  Your example cause the warning " & before arraay or function
ignored."



More information about the Comp.lang.c mailing list