Mailing Lists: Apple Mailing Lists

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

Re: NSData dataWithBytes problem on Intel



On 3/21/07, Shawn Erickson <email@hidden> wrote:
On 3/21/07, Sam Waters <email@hidden> wrote:
> The solution:
>
> Here's what I was doing:
>
> NSData * dTempData = [NSData dataWithBytes:[self Function]   length:iLen];
>
> iLen is a class variable that got updated in Function. On the PPC iLen would be
> updated in time, but on the Intel it wouldn't be. Oddly enough that same line
> of code works fine on my Windows XP port. (in C++ syntax of course)

Humm... that seems like a possible compiler bug to me.

No, it is not a bug. The order of evaluation for parameters to functions is not defined (in C, C++ or Objective-C).

The compiler should see that a message is being sent ("[self
Function]") and require the reloading of any non-local non-const
variables used in the second message before attempting to send the
second message ([NSData dataWithBytes:...]).

Wrong.

As Andy notes maybe the Objective-C standard (maybe even C) doesn't
make a statement on any particular evaluation order of parameters like
it does for the evaluation of boolean logic statements (short-circuit
evaluation)... humm... IMHO I believe the compiler should ensure any
nested messages are sent before reading any non-local non-const
variables despite any definition (or lack thereof) about evaluation
order.

To do that would remove many optimization opportunities for compilers.

It may just be one of those undefined things... aka like "i =
++i + 1;".

It is exactly like that.

--
Clark S. Cox III
email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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
References: 
 >Re: NSData dataWithBytes problem on Intel (From: Sam Waters <email@hidden>)
 >Re: NSData dataWithBytes problem on Intel (From: Sam Waters <email@hidden>)
 >Re: NSData dataWithBytes problem on Intel (From: "Shawn Erickson" <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.