optimization
Stan Friesen
sarima at gryphon.CTS.COM
Mon Apr 25 08:24:06 AEST 1988
In article <20065 at think.UUCP> barmar at fafnir.think.com.UUCP (Barry Margolin) writes:
>
>But my main objection to your blanket statement above is that it
>requires code that ACCIDENTALLY works when unoptimized to continue
>working when optimized.
>
I want to add my affirmation of this! Code that ACCIDENTALLY works
is more common than many people realize. One of the worst cases was in a
program I was maintaining(written by someone else) that had something
like the following:
func(args)
type args;
{
type .... /* whole bunch of auto variable declarations */
.
.
int cur_pos; /* Almost the last auto declared */
.
.
.
Code that uses cur_pos as if it were static;
}
And it WORKED, at least until I made some minor changes elsewhere.
You see, the auto variables were "pushed" on the stack in the order of
declaration, and no other function had nearly as many auto variables as
func(). Thus the value in cur_pos was left undisturbed on the stack! Talk
about working *accidentally*!!!! (The programmer in question had already
been terminated for incompetence).
--
Sarima Carandolandion sarima at gryphon.CTS.COM
aka Stanley Friesen rutgers!marque!gryphon!sarima
Sherman Oaks, CA
More information about the Comp.lang.c
mailing list