After looking at it a little more, I agree that this is not a bug. Alan and
Steve and Marshall (who wrote me directly) are right, this is a case of
register coloring. Basically the optimizer looks at the lifetime of the
variable x and determines whether it's safe to reuse the same memory space
for variable y. In the case of the code snippet below, it's correct since x
is never reused after the assignment to it.

If you don't want this to happen, there are two things you could do:
a) turn off Global Optimizations for debugging. We typically recommend avoid
turning off all opts for debugging to avoid situations like this.
b) rewrite that portion of your code to avoid the optimizer performing
register coloring. In the case of the code snippet below, this code would
avoid register coloring:

int x;
int y;
x = 1;
y = 5;
if (x == 1) {}
else;

Notice how the code actually makes use of x, thus causing the optimizer to
avoid using register coloring for x.

Hope this helps.

Rgds,
JK Lam
Metrowerks Technical Support

----- Original Message -----
From: Alan Pinstein <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 20, 1999 12:47 PM
Subject: Re:


> Can't you turn off the 'Global Register Allocation' pref for debugging,
> which will prevent this side-effect called 'register coloring?'
>
>
> Alan Pinstein
> Synergy Solutions, Inc.
> http://www.synsolutions.com
> 1-800-210-5293
>
>
> >>> and step through it, the integers will have the same value in the
> >>> variables window.
> >>> Is this something that only happens to me or are others experiencing
> >>> problems ?
> >
> >I've noticed this for months. I always thought it was CodeWarrior's
smarts
> >about variable allocation. In this case, once you assign 1 to x, you no
> >longer use it, so it reuses the same memory location for y.
> >
> >Regards,
> >Steve Mann
> >
> >-------------------------------------------
> >Creative Digital Publishing Inc.
> >1317 Palm Street, San Luis Obispo, CA 93401-3117
> >-------------------------------------------
> >805.788.0138            805.593.3811 (fax)
> >[EMAIL PROTECTED]       http://www.cdpubs.com
>
>
>
>

Reply via email to