>> >For example:
>> >
[quoted text clipped - 26 lines]
>Line 1: unsigned long test_date = 0;
>Line 6: test_date = message_array[i].date_time;
I didn't know if you counted comments or blank lines. These lines have
breakpoints for me.
>> It may be your code is not used and just dead
>> stripped out
>
>Well, clearly it is being used since the variable is having a value
>assigned to it, then is being tested against the value of oldest_date.
Not necessarily for example the compiler can see that your code does
nothing but increment from zero to some number and skip all of the loops
and just go to the last number.
>Perhaps I don't understand your definition of "not being used" in this
>context.
it is optimized out and not used or isn't used period.
Ron

Signature
Metrowerks, maker of CodeWarrior - "Software Starts Here"
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>
Charles Thomas - 23 Jan 2004 19:28 GMT
>> > unsigned long test_date = 0;
>> >
[quoted text clipped - 8 lines]
>> > }
>> > }
> >Well, clearly it is being used since the variable is having a value
> >assigned to it, then is being tested against the value of oldest_date.
>
> Not necessarily for example the compiler can see that your code does
> nothing but increment from zero to some number and skip all of the loops
> and just go to the last number.
I guess I'm just not following you. If the code is creating a variable
test_date and assigning the value of message_array[i].date_time to it,
then comparing that value to see if it's less than the value in the
variable oldest_date, how can it be considered "not used"?
Not only is it used, but the entire method fails if this comparison
isn't done.
CT
MW Ron - 23 Jan 2004 22:31 GMT
>>> > unsigned long test_date = 0;
>>> >
[quoted text clipped - 20 lines]
>then comparing that value to see if it's less than the value in the
>variable oldest_date, how can it be considered "not used"?
I'm talking generic and you are talking specifics which is why you may
not be follwoing.
However the point is if this has optimizations on, no matter what,
processor scheduling, peephole etc then it may be optimized away, you
can't do debugging and see every line if optimizations are on.
>Not only is it used, but the entire method fails if this comparison
>isn't done.
OK suppose instead of
test_date = message_array[i].date_time;
if (test_date < oldest_date)
you used
if (message_array[i].date_time < oldest_date)
I'm telling you that the compiler with optimizations on is smart enough
to figure that out and make the substitution thereby making the first
and sixth lines unused
Ron

Signature
Metrowerks, maker of CodeWarrior - "Software Starts Here"
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>
Charles Thomas - 26 Jan 2004 17:25 GMT
> >isn't done.
> OK suppose instead of
[quoted text clipped - 9 lines]
> to figure that out and make the substitution thereby making the first
> and sixth lines unused
Ah, I see your point now. Thanks for clarifying.
The reason I often use the more verbose method is *specifically* to
debug those values while stepping through the code. If message_array
isn't a variable local to the method in question there's no way to check
its value as you're stepping through the code (it doesn't show up in the
variable list of the debugger), so I create a local copy of it in the
method to check the value during debugging.
This used to be a good way to do this, but now with optimizations I've
been outsmarted by the compiler!
I guess I've not yet found all the places to turn off optimizations.
I'll keep looking.
CT
MW Ron - 27 Jan 2004 04:09 GMT
>> >isn't done.
>> OK suppose instead of
[quoted text clipped - 25 lines]
>
>I'll keep looking.
declare the variable volatile then it can't be optimized away.
Ron

Signature
Metrowerks, maker of CodeWarrior - "Software Starts Here"
Ron Liechty - MWRon@metrowerks.com - <http://www.metrowerks.com>