Ah ok. I was bit by something similar a few years ago. I had forgotten to put the prototype in my class interface and believed the compiler was using a prototype from an unrelated class which had different arg and return types. But the twist was the missing prototype caused the default id return and '...' arg types to be used (determined through asm studying). The presence of the other class's prototype was just suppressing the usual 'may not respond to selector' warning.

As far as trashing memory it was very likely trashing a floating point register your calling code was using and eventually using the trashed value for calculations and/or storing it to memory. For instance on i386 it might have had a float the calling code was using in fp0 and expecting the return value of your called method to come back on EAX, therefore believing fp0 would stay unchanged. But the called method was writing its return in fp0 (destroying the original value) and the calling code was casting whatever junk was in EAX to your float. Actual register names might differ but the effect is the same.


On Jun 8, 2008, at 6:29 AM, Graham Cox wrote:

No, this is not it. The method definitely did have a prototype - in fact it had *two*, differing only in return type. Judging by the assembler code, it used the one returning an int (actually an enum) not a float. It's still unclear why this generated code that trashed memory, but it did. It also did silently cast the result as well, which is perhaps why no warning was issued, because in some cases that's the desired behaviour.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to