K&R App A, par. 8 & 8.2, on Declarations, Defaulting.
John Bruner
jdb at mordor.UUCP
Fri Jul 13 06:11:26 AEST 1984
Allowing automatic variables to be declared with "x = 1;" instead of
"int x = 1;" can produce ambiguities. Consider
int *p = &something; int *p = &something;
func() func()
{ {
*p = 0; int *p = 0;
return(p); return(p);
} }
This should not treat "*p = 0;" as an automatic variable definition;
rather, it must be interpreted as a reference to the global "p".
Also, "int *p = 0;" does not do the same thing as "int *p; *p = 0;".
The first case sets "p" to NULL, the second case sets the integer
pointed-to by (the garbage) pointer "p" to zero.
--
John Bruner (S-1 Project, Lawrence Livermore National Laboratory)
MILNET: jdb at mordor.ARPA [jdb at s1-c] (415) 422-0758
UUCP: ...!ucbvax!dual!mordor!jdb ...!decvax!decwrl!mordor!jdb
More information about the Comp.lang.c
mailing list