• 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: NSData dataWithBytes problem on Intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData dataWithBytes problem on Intel


  • Subject: Re: NSData dataWithBytes problem on Intel
  • From: "Clark Cox" <email@hidden>
  • Date: Thu, 22 Mar 2007 21:45:15 -0700

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:
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>)

  • Prev by Date: Re: setKeyEquivalent: gives two action invocations
  • Next by Date: Re: Twain, Image Capture, Intel, PPC
  • Previous by thread: Re: NSData dataWithBytes problem on Intel
  • Next by thread: Re: NSData dataWithBytes problem on Intel
  • Index(es):
    • Date
    • Thread