GC, variable optimized away wrongly?
GC, variable optimized away wrongly?
- Subject: GC, variable optimized away wrongly?
- From: Nick Rogers <email@hidden>
- Date: Wed, 25 Nov 2009 18:20:58 +0530
Hi,
In my app running on snow leopard, in a particular situation I'm getting an undesired behavior.
Debugging a "for loop" shows a still in scope variable being optimized away.
code: (problem occurs after the loop has been iterated thousands (may be more) of time.
for loop statement here()
{
NSDate *currentDate = [NSDate date];// ok value here
NSTimeInterval interval = [currentDate timeIntervalSinceDate:startDate];// ok value here
NSTimeInterval etaDouble = interval * ((totalBlocks - blockCount) / blockCount); // * debugger doesn't list this variable, mouse shows a pop up saying "variable optimized away by compiler"
int eta = (int)etaDouble; // value is 0 here instead of something
int seconds = eta % 60; // value is 0 here instead of something
int minutes = (eta / 60) % 60; // value is 0 here instead of something
int hours = ((eta / 60) / 60) % 24; // value is 0 here instead of something
int days = ((eta / 60) / 60) / 24; // value is 0 here instead of something
}
Why the certain variables are not listed in debugger window (only in GC-only projects)?
Why is etaDouble is being optimized away?
Any suggestions?
Wishes,
Nick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden