discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling [GormObjectEditor -draggingUpdated:] with incorrect signatur


From: David Chisnall
Subject: Re: Calling [GormObjectEditor -draggingUpdated:] with incorrect signature. Method has I12@0:4@8, selector has i12@0:4@8
Date: Fri, 17 Dec 2010 14:02:04 +0000

On 17 Dec 2010, at 13:42, Fred Kiefer wrote:

> First of all, Gorm is wrong in having all these methods return unsigned,
> it should be NSDragOperation. But this doesn't explain why libobjc2 has
> a problem here.
> David, could you please have a look at that and see what the difference
> between these two types is?


The method that is being called returns an unsigned int, but the selector 
returns a signed int (I vs i - difficult to see in some fonts).  libobjc2 
catches cases where you call a method with the wrong types and logs a message 
before calling the incorrectly-typed method.  

Eventually this will be a hard error, because calling a method with the wrong 
types can cause stack corruption[1].  It's probably safe in this specific case 
(although it can result in some weird bugs because you have an implicit integer 
cast that you may be unaware of), but in nontrivial cases (e.g. returning an 
integer, expecting an object) it can be a serious problem.  

There is a hook that can be called to perform fixup.  If you link against 
LanguageKit, then it automatically generates and inserts a method at run time 
that can box / unbox primitives as objects.

For more information, see these two blog posts:

http://etoileos.com/news/archive/2010/09/01/1228/
http://etoileos.com/news/archive/2010/09/01/1444/

David

-- Sent from my IBM 1620




reply via email to

[Prev in Thread] Current Thread [Next in Thread]