Path: utzoo!mnetor!uunet!husc6!ncar!gatech!mcnc!decvax!decwrl!pyramid!prls!philabs!micomvax!zap!iros1!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.lang.c Subject: Re: Uninitialized global data (was Re: Global variables) Message-ID: <978@mcgill-vision.UUCP> Date: 8 Mar 88 05:06:30 GMT References: <1744@phoenix.Princeton.EDU> Organization: McGill University, Montreal Lines: 34 In article <1744@phoenix.Princeton.EDU>, rjchen@phoenix.Princeton.EDU (Raymond Juimong Chen) writes: > From someone whose attribution has since vanished: >> The manual seems to indicate that only initialized global data will >> go here, but isn't all global data implicitly initialized to zero if >> not otherwise specified? All statically-allocated data are initialized to zero unless they are explicitly initialized to something else. This includes both things declared static and normal global data. > I believe that global data initialized to zero go into a special > segment called "bss". What it means is (I think) that when the > program is loaded, the loader allocates the requisite amount of space > and initializes it to zero at runtime. This is a UNIXism; not all systems have anything like UNIX's bss segment, and even fewer of them actually call it bss. As to what it means, you are perfectly correct. It's sort of a trivial form of data compression: it's something like run-length compression for zero data only. On the other hand, this has its ambiguities. Imagine a machine on which integer zero, floating zero, and null pointer have three different bit patterns. Now, what is the following datum on program startup? Presumably it's one of the three, or possibly all-bits-zero regardless of whether this matches any of the above three.... Could someone with access to the draft clear this up? union { int i; float f; char *cp; } funny; der Mouse uucp: mouse@mcgill-vision.uucp arpa: mouse@larry.mcrcim.mcgill.edu