Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!apple!voder!procase!roger From: roger@procase.UUCP (Roger H. Scott) Newsgroups: comp.lang.c++ Subject: Re: C++ coding standards (Comment needed) Keywords: standard,variables Message-ID: <184@logo.procase.UUCP> Date: 22 Aug 90 01:49:06 GMT References: <2161@runxtsa.runx.oz.au> <1990Aug13.182226.24141@alias.uucp> Reply-To: roger@procase.UUCP (Roger H. Scott) Organization: proCASE Corporation, Santa Clara, CA Lines: 11 In article <1990Aug13.182226.24141@alias.uucp> bmcphers@alias.UUCP (Brent McPherson) writes: >... >Finally, common sense should prevail. If a variable is first assigned a value >within a loop it should be declared outside the loop just in case the compiler >decides to create the variable on the stack for each loop iteration. If your compiler is really dumb enough to do that for an ordinary C-sort of variable you need to get a new compiler. The only case where I can imagine that such a thing would be worth restructuring my code over is declarations of automatic objects with constructors and/or destructors - it is unfortunate that C++ compilers won't be smart enough to optimize such things in the forseeable future.