Xref: utzoo comp.sources.d:2094 comp.lang.c:10101 Newsgroups: comp.sources.d,comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Flex on MSDOS and C block structure Message-ID: <1988May15.002127.413@utzoo.uucp> Keywords: nested declarations flex msdos Organization: U of Toronto Zoology References: <4060@killer.UUCP> Date: Sun, 15 May 88 00:21:27 GMT > ... Does the ANSI standard (or > K&R for that matter) have anything to say about exiting a context and > reentering it saving (or not saving) the state of local variables? All definitions of C that I'm aware of make it quite clear that the values of uninitialized local variables are unknown when the block containing them is entered, *regardless* of whether the block was executed before and gave them a value then. Old values go away when the block is exited. > Might > the fact that this code seems to work almost everywhere imply that Unix > and VMS (AT&T derived?) C compilers allocate local variables on the > entry to the function, rather than entry to the block?... Correct in general. But it's not something one should depend on, of course. Even if allocation is at function-entry time, clever compilers may well re-use the space for something else after the block is exited. -- NASA is to spaceflight as | Henry Spencer @ U of Toronto Zoology the Post Office is to mail. | {ihnp4,decvax,uunet!mnetor}!utzoo!henry