Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mordor.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!cbosgd!ihnp4!houxm!houxz!vax135!cornell!uw-beaver!tektronix!hplabs!hao!seismo!ut-sally!mordor!jdb From: jdb@mordor.UUCP (John Bruner) Newsgroups: net.lang.c Subject: Re: K&R App A, par. 8 & 8.2, on Declarations, Defaulting. Message-ID: <4614@mordor.UUCP> Date: Thu, 12-Jul-84 16:11:26 EDT Article-I.D.: mordor.4614 Posted: Thu Jul 12 16:11:26 1984 Date-Received: Wed, 18-Jul-84 02:20:48 EDT References: hou3c.664 <180@log-hb.UUCP> <1027@hao.UUCP> <2905@ecsvax.UUCP> Organization: S-1 Project, LLNL Lines: 21 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@mordor.ARPA [jdb@s1-c] (415) 422-0758 UUCP: ...!ucbvax!dual!mordor!jdb ...!decvax!decwrl!mordor!jdb