• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
GC, variable optimized away wrongly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: GC, variable optimized away wrongly?
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Best approach to write an uninstaller for osx
  • Next by Date: Re: GC, variable optimized away wrongly?
  • Previous by thread: Re: URLWithString fails to fails with bad string
  • Next by thread: Re: GC, variable optimized away wrongly?
  • Index(es):
    • Date
    • Thread