Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site mordor.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!mordor!jdb From: jdb@mordor.UUCP (John Bruner) Newsgroups: net.lang.c Subject: Re: Global ptrs init to NULL or 0000? Message-ID: <4217@mordor.UUCP> Date: Mon, 4-Nov-85 19:58:27 EST Article-I.D.: mordor.4217 Posted: Mon Nov 4 19:58:27 1985 Date-Received: Tue, 5-Nov-85 07:47:04 EST References: <772@whuxl.UUCP> <4513@alice.UUCP> Reply-To: jdb@mordor.UUCP (John Bruner) Organization: S-1 Project, LLNL Lines: 22 One ramification of moving uninitialized pointers from the BSS segment into the DATA segment is that the common practice of defining global variables by putting the statement "int *p;" in multiple files will cause load errors. (There should be exactly one definition; the rest should be "extern int *p;".) A *lot* of C programs are written this way. (Wasn't AT&T forced to back away from a fix to the C loader [Sys Vr1?] that prevented this sloppy practice?) This is just one example of how much inertia must be overcome when implementing C on a machine where (foo *)0 does not have the same representation as (int)0. A less-common but related problem is the use of calloc(), which returns memory which is guaranteed to be zero. Programs that calloc() pointers (usually within structures) and do not initialize those pointers are making the nonportable assumption that (foo *)0 is an all-zero bit pattern. -- John Bruner (S-1 Project, Lawrence Livermore National Laboratory) MILNET: jdb@mordor [jdb@s1-c.ARPA] (415) 422-0758 UUCP: ...!ucbvax!dual!mordor!jdb ...!seismo!mordor!jdb