• 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
Strange behaviour of iPhone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange behaviour of iPhone


  • Subject: Strange behaviour of iPhone
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sat, 21 Sep 2013 23:00:06 +0700

I just created a new iOS app - universal, Master-Detail, no CoreData and added the following into application:didFinishLaunchingWithOptions:

// --- #define BUG_FIX1

#if 		DEBUG
	NSLog(@"%s Debug build - no bugs here",__FUNCTION__);
#else	//	Release
	#ifdef BUG_FIX1
		NSLog(@"%s Release build with bug-fix",__FUNCTION__);
	#else
		NSLog(@"%s Release build with bug",__FUNCTION__);
	#endif
#endif	//	debug or release

typedef struct
{
	double	size;
	double	value;

} tupel_t;

tupel_t *tupelsP;
NSUInteger nbrOfTupels;

//	the parenthesis in the next line is important
{
	tupel_t tupels[] = 	//	need more than 2 tupels for the bug
	{
		{ 6, 8},
		{48, 8},
		{99, 7}
	};

	tupelsP = tupels;
	nbrOfTupels = sizeof(tupels) / sizeof(tupel_t);
	#ifdef BUG_FIX1
		NSLog(@"%s tupelsP = %p",__FUNCTION__, tupelsP);	//	printing tupelsP fixes the bug
	#else
		NSLog(@"%s nbrOfTupels %lu",__FUNCTION__, (unsigned long)nbrOfTupels);
	#endif
}

NSLog(@"%s tupelsP %p first (should be 6): %g last (should be 99): %g",__FUNCTION__,
	tupelsP, tupelsP->size, (tupelsP+nbrOfTupels-1)->size);

Then run the Release build and got:

 tupelsP 0xbfffcaf8 first (should be 6): 2.00737e-302 last (should be 99): 2.09289e-302

Is this legal C-code (the compiler thinks it is)?

What am I doing wrong?

Gerriet.



_______________________________________________

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


  • Prev by Date: Re: CGImageRef as a property of a cocoa object
  • Next by Date: Scroll a collection
  • Previous by thread: iAd banner on iOS 7 simulator
  • Next by thread: Re: Strange behaviour of iPhone
  • Index(es):
    • Date
    • Thread