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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to