Pointer to Function Anomaly

utzoo!decvax!harpo!npoiv!npois!houxm!houxa!houxi!houxz!ihnp4!ihuxe!ryl utzoo!decvax!harpo!npoiv!npois!houxm!houxa!houxi!houxz!ihnp4!ihuxe!ryl
Tue Jan 11 15:29:15 AEST 1983


Why does the following program compile without a complaint,
when there is an obvious redefinition of slime? (Lint does catch
this, though.)

	main()
	{
		int	slime();
		static	int (*slime)();
	
		(*slime)();
	}
	slime()
	{
		printf("hello\n");
		return(0);
	}

This obviously has something to do with pointers to functions,
since it won't work for any other types.  The second declaration
also needs to be static.  Incidentally, because statics get
initialized to zero, this program ends up being a recursive
call on main until you run out of stack space; it never prints
"hello."

	Bob Lied	ihnp4!ihuxe!ryl	BTL-Indian Hill



More information about the Comp.lang.c mailing list