Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-lcc!rutgers!sri-unix!ctnews!pyramid!amdahl!cerebus!fai!wjvax!brett From: brett@wjvax.UUCP (Brett Galloway) Newsgroups: comp.lang.c Subject: Re: union initialization Message-ID: <881@wjvax.wjvax.UUCP> Date: Thu, 30-Apr-87 11:49:03 EDT Article-I.D.: wjvax.881 Posted: Thu Apr 30 11:49:03 1987 Date-Received: Sun, 3-May-87 05:56:19 EDT References: <3290@burdvax.PRC.Unisys.COM> <1722@plus5.UUCP> <455@haddock.UUCP> <6483@mimsy.UUCP> Reply-To: brett@wjvax.UUCP (Brett Galloway) Organization: Watkins-Johnson Co., San Jose, Calif. Lines: 28 In article <6483@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >To refresh memories (in some cases) or provide background (in others), >the problem, or symptom, is this: Uninitialised variables that have >static allocation (that is, globals and local static variables) are, in >C, defined as though they were initialised to `zero' [example] >In most existing systems, this is trivial because 0 and 0.0 and >(char *)0 are all all-zero bit patterns, and operating systems or >runtime startups need know only how many bits of zeros are required >(the infamous `bss' space). There are machines, though, in which >not all of these are all zero bit patterns ... This has always bugged me about C -- the requirement that uninitialized variables be implicitly initialized to 'zero` is problematic. Where binary 0000...000 is not `zero' for every type, it is wasteful, increasing the size of binaries. It is even more wasteful for embedded applications (on PROM) where static initialization must be done at run-time. The problem is that MOST of the time, the fact that uninitialized statics are initialized to 'zero` is NOT used. It would have been better if K&R had not imposed this requirement. It would also have made feasible the (I think) better solution to union and structure initialization proposed by Karl Heuer. Oh well ... wishful thinking. -- ------------- Brett Galloway {pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvaxring ir