enum function bug?

Guy Harris guy at sun.uucp
Fri Sep 12 19:33:32 AEST 1986


> I want to pass a
> 	pointer to function returning "bool"
> to a function, but lint says I'm not doing it right.  I think I am,
> aren't I? ... Is this a bug?


Yes, and yes.  PCC converts "enum"s into "char"s, "short"s, or "int"s at a
fairly early stage in its processing.  Unfortunately, this means "lint" does
also.  As such, "pointer to function returning enum" gets converted to
"pointer to function returning char/short/int", which collides with the
formal argument of "f".  In this particular case, I tried it and it gave the
errors listed; I changed the function pointer declarations to "int (*xx)()"
and it passed.

The fix is not to convert "enum"s in that fashion in "lint", and fix pass 2
to check that enum formal arguments match the actual arguments used.

You can tell the parts of the language that were added later; the front end
of PCC doesn't really handle them right.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)



More information about the Comp.lang.c mailing list