Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: "...the value becomes,indeterminate each time the declaration is reached" Date: Tue, 29 Jan 2019 12:13:56 -0800 Organization: None to speak of Lines: 31 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="d4c283bddc07f1e18e9f0e3ba0b33641"; logging-data="28198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rpJLZkONQB3tjTVSEV/Jd" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:+HSpn6820J6gqTLx6KcF8sREpRc= sha1:53wWKWW9Qe1bDAKZnEixh14Qofo= Xref: csiph.com comp.lang.c:140385 ram@zedat.fu-berlin.de (Stefan Ram) writes: > Andrey Tarasevich writes: >>Why would we want to "reset" an object to an indeterminate value *each >>time* we reach its declaration within its block? (As opposed to giving >>it indeterminate value only *initially*?) > > Maybe to given the implementation leeway for optimizations, > maybe to help static code analyzers, > maybe to making it easier to implement C. > >>Consider the following code sample. According to 6.2.4 the lifetime of a >>non-VLA automatic objects in C is the full block that contains its >>declaration. > > Lifetime is a duration during an execution. > > A block is a region in the source code. > > They cannot be equal because they are different > categories of entities. Yes, the lifetime is the period of execution of the block. "For such an object that does not have a variable length array type, its lifetime extends from entry into the block with which it is associated until execution of that block ends in any way." -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */