Path: utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: C++ coding standards (Comment needed) Keywords: standard,variables Message-ID: <11290@alice.UUCP> Date: 5 Sep 90 02:48:05 GMT References: <56642@microsoft.UUCP> <41673@think.Think.COM> <56953@microsoft.UUCP> <57167@microsoft.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 23 In article <57167@microsoft.UUCP>, jimad@microsoft.UUCP (Jim ADCOCK) writes: > | func() > | { { int i; .... } > | { int j; .... } > | } > |i and j's live ranges do not overlap, so they can (and do with some compilers) > |share the same storage location. > Yes, but C++ defines that destruction of named objects be on exit from > scope [with few exceptions], thus greatly restricting a compilers from > performing these optimizations on other than primitives. But in this example, the scopes of `i' and `j' end at the close braces at the end of their respective lines. Therefore a C++ implementation is certainly entitled to let `i' and `j' share storage, as long as it destroys `i' before constructing `j.' -- --Andrew Koenig ark@europa.att.com