Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Heads Up: Code generation bug



Just stumbled onto this and it cost me quite a few hours of frustration. Hopefully someone else can benefit from this...

I just reported to Apple a code generation bug I discovered today in Xcode 2.4.1 and 2.5. Under some circumstances (don't know exactly what though),enabling optimized code generation results in incorrect execution.

Steps to Reproduce:

1) Download and decompress sample project "GP" from
<http://www.muratnkonar.com/source-code/GP.zip>

2) Note that the file "FooVoo.mm" declares as a constant an NSPoint named "kItemLabelsOrigin" with value {20, 8}.

3) Note also that in the init method of FooVoo, an assigment from kItemLabelsOrigin to a local variable "itemNameOrigin" is made. Immediately after the assigment, the x and y coordinates of itemNameOrigin are compared to the x and y coordinates of kItemLabelsOrigin. Depending on the result, a message is logged to the console. Then the values of kItemLabelsOrigin and itemNameOrigin are logged to the console.

Here's the code in FooVoo.mm:

const NSPoint kItemLabelsOrigin = NSMakePoint(20, 8);

@implementation FooVoo

- (id) init
{
    NSPoint itemNameOrigin = kItemLabelsOrigin;

if (itemNameOrigin.x == kItemLabelsOrigin.x && itemNameOrigin.y == kItemLabelsOrigin.y)
{
NSLog(@"itemNameOrigin == kItemLabelsOrigin");
}
else
{
NSLog(@"itemNameOrigin != kItemLabelsOrigin");
}


NSLog(@"kItemLabelsOrigin = %@", NSStringFromPoint (kItemLabelsOrigin));
NSLog(@"itemNameOrigin = %@", NSStringFromPoint(itemNameOrigin));


    return [super init];
}

@end


4) Build and run the project using the Release configuration (which has Optimization level set to "Fastest, Smallest"), observing messages logged to the console.


Expected Results:

Something like:

   Running…
   2007-11-13 20:14:11.200 GP[880] itemNameOrigin == kItemLabelsOrigin
   2007-11-13 20:14:11.201 GP[880] kItemLabelsOrigin = {20, 8}
   2007-11-13 20:14:11.201 GP[880] itemNameOrigin = {20, 8}

Note that the log indicates that itemNameOrigin and kItemLabelsOrigin have (as expected) the same value.

Actual Results:

   Running…
   2007-11-13 20:16:39.953 GP[944] itemNameOrigin != kItemLabelsOrigin
   2007-11-13 20:16:39.953 GP[944] kItemLabelsOrigin = {20, 8}
   2007-11-13 20:16:39.953 GP[944] itemNameOrigin = {0, 0}

The assigment fails!

_murat


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.