• 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: objc_msgSend problems on x86
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objc_msgSend problems on x86


  • Subject: Re: objc_msgSend problems on x86
  • From: Rosyna <email@hidden>
  • Date: Thu, 9 Feb 2006 05:18:00 -0700

Ack, at 2/9/06, Nicko van Someren said:

On 9 Feb 2006, at 10:25, Rosyna wrote:

I've noticed when running code like:

bool isEqual=objc_msgSend(string, NSSelectorFromString(CFSTR("isEqualToString:")), otherString);

On the PPC will work just fine 100% of the time. If I run the same code on the ICBMs it'll return true even when the strings weren't equal at all in some rare cases. It also shows an error in GCC

The error might be conveying useful information. Would you like to tell us what it says?

If I had typed BOOL instead of bool it would have said something about casting to a smaller size. But it's bool so it won't (on PPC).


Even worse was trying something like:

if (objc_msgSend(string, NSSelectorFromString(CFSTR("isEqualToString:")), otherString))

which returns true the far majority of the time even when it the strings are not equal. However, if I change the code to read:

if ((signed char(*)(id, SEL, id)objc_msgSend)(string, NSSelectorFromString(CFSTR("isEqualToString:")), otherString))

it always returns the correct value. Is there a reason for this change between the PPC and the x86?

In your old code you were taking the result of objc_msgSend as a BOOL; it fails and gives you an error. In the later case you explicitly tell the compiler that it is something else and it works.
Two things to note: firstly, the function objc_msgSend returns an id, not a BOOL, which is probably what your error is about. Secondly, in the Universal Binary Programming Guidelines [1] you'll find that the BOOL type is represented differently on the Intel processors compared to how it was on the PPC. The first observation means that your original code was making an assumption about how something works and the second observations means that how things work with respect to BOOL types has changed, so I'm guessing your code fails because your assumption is no longer correct.

Where are you seeing this in the universal programming guidelines? BOOL and bool are two distinct types. bool has changed on the ICBMs but I don't see any indication that the behaviour of BOOL has.


if (objc_msgSend(string, NSSelectorFromString(CFSTR("isEqualToString:")), otherString))

The above code produces no error. But it does not work 100% of the time on the ICBMs. It works 100% of the time on the PPCs. Whether it works or not on the ICBMs seems to be a total crapshoot.
--



Sincerely, Rosyna Keller Technical Support/Holy Knight/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People

It's either this, or imagining Phil Schiller in a thong.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: objc_msgSend problems on x86
      • From: Guy English <email@hidden>
References: 
 >objc_msgSend problems on x86 (From: Rosyna <email@hidden>)
 >Re: objc_msgSend problems on x86 (From: Nicko van Someren <email@hidden>)

  • Prev by Date: Re: objc_msgSend problems on x86
  • Next by Date: Re: Core Data and @count keypath
  • Previous by thread: Re: objc_msgSend problems on x86
  • Next by thread: Re: objc_msgSend problems on x86
  • Index(es):
    • Date
    • Thread