Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!flaps From: flaps@utcsri.UUCP (Alan J Rosenthal) Newsgroups: comp.sys.amiga Subject: Re: Is this a Manx Bug? Message-ID: <4050@utcsri.UUCP> Date: Mon, 2-Feb-87 17:52:03 EST Article-I.D.: utcsri.4050 Posted: Mon Feb 2 17:52:03 1987 Date-Received: Wed, 4-Feb-87 05:40:25 EST References: <958@tekred.TEK.COM> Reply-To: flaps@utcsri.UUCP (Alan J Rosenthal) Organization: University of Toronto Lines: 31 Keywords: auto variables Summary: In article <958@tekred.TEK.COM> joels@tekred.UUCP writes: >later I was reading my C manual and it said that all 'auto' variables >should be automaticly initialized to zero at every entry to the subroutine. >The UNIX C does this, but Manx does not. Is this a Manx bug? As Matt pointed out, the initial value in this case is undefined (see the middle of page 198 of K&R). UNIX C does not do this. However, when memory is allocated to a process in the first place it is zeroed. Therefore many things which are supposed to contain "garbage" (such as uninitialized auto variables) in fact will contain zero SOMETIMES. Counting on this is stupid! In addition, this is generally not the case with micros, as the reason for this zeroing of memory is to protect users from having other users see their memory contents just deallocated. (An example of a devious use possible on some mainframes if they didn't zero memory (but not applicable to unix) is allocating a large amount of memory right after someone logs in & looking through it to see if their password is there.) -- Alan J Rosenthal UUCP: {backbone}!seismo!mnetor!utcs!flaps, ubc-vision!utai!utcs!flaps, or utzoo!utcs!flaps (among other possibilities) ARPA: flaps@csri.toronto.edu CSNET: flaps@toronto BITNET: flaps at utorgpu