Re: NSData dataWithBytes problem on Intel
Re: NSData dataWithBytes problem on Intel
- Subject: Re: NSData dataWithBytes problem on Intel
- From: Greg Titus <email@hidden>
- Date: Wed, 21 Mar 2007 12:47:15 -0700
On Mar 21, 2007, at 12:36 PM, Shawn Erickson 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.
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:...]).
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. It may just be one of those undefined things... aka like "i =
++i + 1;".
Yep, the C standard doesn't make any promises about order of
evaluation of parameters, which is what this ends up being (a
function call to objc_msgSend()). See ANSI C standard A7.3.2: "The
order of evaluation of arguments is unspecified; take note that
various compilers differ."
Hope this helps,
- Greg
_______________________________________________
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:
This email sent to email@hidden