• 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
Re: Heads Up: Code generation bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Heads Up: Code generation bug


  • Subject: Re: Heads Up: Code generation bug
  • From: David Spooner <email@hidden>
  • Date: Wed, 14 Nov 2007 07:10:25 -0700

If you change the initialization of your global variable to

	const NSPoint kItemLabelsOrigin = (NSPoint){20, 8};

then it works fine.

dave


On 13-Nov-07, at 9:50 PM, m wrote:

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:
40conversionworks.com


This email sent to email@hidden


_______________________________________________

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: Heads Up: Code generation bug
      • From: m <email@hidden>
References: 
 >Heads Up: Code generation bug (From: m <email@hidden>)

  • Prev by Date: Re: Change a NSMenu's shape?
  • Next by Date: Stop the animation while it is in progress?
  • Previous by thread: Re: Heads Up: Code generation bug
  • Next by thread: Re: Heads Up: Code generation bug
  • Index(es):
    • Date
    • Thread