Bug in 4.2BSD C compiler...

Ed Gould ed at mtxinu.UUCP
Sat May 11 16:04:22 AEST 1985


>                                  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.

??? I sure don't read it that way.  What you may be misreading is that
a declaration of a function, e.g.

	int funct();

is in effect declaring funct to be, in some semantic equivalency sort of way,
to be a pointer to a function.  The sequence

	f() {
	    int f2();
	    int (*f3)();

	    f3 = f2;
	    (*f3)();
	}

is reasonable and legal; the sequence

	f() {
	    int f2();
	    int *f3();

	    f3 = f2;
	    (*f3)();
	}

makes no real sense.  The key is that () binds tighter than *.  Of course,

	*f3();

(assuming that f3 is a function returning a pointer) is also reasonable,
but has *very* different meaning.

-- 
Ed Gould		    mt Xinu, 2910 Seventh St., Berkeley, CA  94710  USA
{ucbvax,decvax}!mtxinu!ed   +1 415 644 0146



More information about the Comp.lang.c mailing list