discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Project Center segfault and nil objects


From: David Ayers
Subject: Re: Project Center segfault and nil objects
Date: Sun, 03 Jul 2005 06:24:27 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1

Serg Stoyan schrieb:
> On Friday 24 June 2005 10:54, David Ayers wrote:
> 
>>Duncan Anker wrote:
>>
>>>I was of the belief that it is legal to send messages to nil in
>>>Objective C, and nothing would happen. This is supposed to be one of the
>>>benefits of it after all, not having to check every object before
>>>sending a message. Given that assumption is true then, is it possible
>>>that nil has a different value between the Project Center support
>>>libraries and the Objective C runtime?
>>
>>In general it is safe to send messages to nil objects.  But in this case
>>the return value is a structure of which specific components are accessed:
>>
>>  origin = NSMakePoint(mouseLocation.x + 8,
>>                       mouseLocation.y - 16 - [ttWindow
>>frame].size.height);
>>
>>If a method returns a structure, it must be protected by a test to
>>insure the receiver is not nil.
> 
> 
> Hmm... It works fine for me (no segfault). So is it depends on operating 
> system runtime or compiler? Anyway I've added check for ttWidow value.
> 

Indeed, it depends (among other things) on the operating system's ABI
(more specifically the calling convention).  It defines how parameters
and return values are passed.  I believe that even if it works for you
here, I am almost certain that it is undefined behavior which just
happens to work.  It can very well be that it many not always work for
you either.

Thanks for fixing it.

Cheers,
David




reply via email to

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