Re: App hangs when displaying any sheet in 10.5 [SOLVED]
Re: App hangs when displaying any sheet in 10.5 [SOLVED]
- Subject: Re: App hangs when displaying any sheet in 10.5 [SOLVED]
- From: Graham Cox <email@hidden>
- Date: Fri, 6 Jun 2008 15:58:47 +1000
I agree, the compiler ought to be able to use the return type to
disambiguate two otherwise identically named methods (or warn of the
mismatch) - but it clearly doesn't.
This is interesting - I looked at the assembly code of the two cases.
Here's the code for the line:
float lp = [lh position];
First for the anonymous type (id):
LM75:
movl 8(ëp), íx
leal L_OBJC_SELECTOR_REFERENCES_35-"L00000000012$pb"(ëx), êx
movl (êx), êx
movl êx, 4(%esp)
movl íx, (%esp)
call L_objc_msgSend$stub
leal LC17-"L00000000012$pb"(ëx), ìx
movl êx, íx
andl $65535, íx
shrl $16, êx
cvtsi2ss êx, %xmm0
cvtsi2ss íx, %xmm1
mulss (ìx), %xmm0
addss %xmm1, %xmm0
movss %xmm0, -44(ëp)
movl -44(ëp), êx
movl êx, -16(ëp)
And for the strongly typed version:
LM75:
movl 8(ëp), íx
leal L_OBJC_SELECTOR_REFERENCES_35-"L00000000012$pb"(ëx), êx
movl (êx), êx
movl êx, 4(%esp)
movl íx, (%esp)
call L_objc_msgSend_fpret$stub
fstps -16(ëp)
I'm not familiar with Intel assembler (if only it were 68K ;-) so I
don't have much clue what's going on, but clearly the code is very
different (and in the second case, looks a lot tighter too). Up to the
call to the object's method they are the same. The first case uses
objc_msgSend which is used for "simple return types". The second case
uses objc_msgSend_fpret which is used to return a double value. What
the rest of the code in the first case is doing with its supposed
"simple return type" I don't know - looks pretty arcane though and
since it damages things, is obviously wrong. Maybe someone who can
read the assembly can throw some additional light?
cheers, Graham
On 6 Jun 2008, at 3:37 pm, Hamish Allan wrote:
On Fri, Jun 6, 2008 at 6:26 AM, Graham Cox <email@hidden>
wrote:
I guess the question is, given an object type 'id', which method
signature
will the compiler go with? Does the return type affect the method
signature?
(In C++ it doesn't for example), so two methods:
- (CGPoint) position;
- (float) position;
might well have identical signatures. The compiler doesn't have an
object
type to narrow it down, so which will it use - the first it finds
maybe.
I'd have thought that in the case:
// id anonymous
float f = [anonymous position];
the compiler ought to assume that the method being used is the one
returning a float, or if not at least warn about an implicit cast from
CGPoint to float. Perhaps if it were -(int)position rather than
-(CGPoint)position, you might not expect a warning, but in that case
you would expect a cast, so it shouldn't break.
However, that does appear to be what is happening. In the absence of
any other explanation, I'd call it a compiler bug.
Hamish
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden