public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libobjc/14382] New: [libobjc] Calling +initialize on a per category basis
@ 2004-03-02 12:36 d dot ayers at inode dot at
  2004-03-02 15:29 ` [Bug libobjc/14382] " pinskia at gcc dot gnu dot org
  2004-03-02 15:49 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: d dot ayers at inode dot at @ 2004-03-02 12:36 UTC (permalink / raw)
  To: gcc-bugs

The file libobjc/README contains the passage:

-----------------------------
+initialize
===========
...each +initialize method is called exactly once (or
never if no methods of that particular class is never called).
Besides this, it is allowed to have several +initialize methods, one
for each category.  The order in which these (multiple methods) are
called is not well defined.  I am not completely certain what the
semantics of this method is for other implementations, but this is
how it works for GNU Objective C.
------------------------------

Yet, currently the invocation of +initialize in libobjc is implemented to send
+initialize only once and does the method lookup manually.

This behavior is compatible to the behavior of the Apple/NeXT runtime.

There is a bug either in the documentation or on the implementation.

Personally I think the documented behavior is very useful, but it would imply
not being able to override +initialize in categories.  Usually that wouldn't
make much sense as these implementations typically have two objectives:
a) insure related classes are initialized
b) initialize static globals which couldn't be initialized in a separate
   category anyway.
But like I said, that's just "usually typical".

I would be in favor of "fixing" the GNU runtime implementation to correspond to
the documentation, *if* the Apple runtime would also implement this feature.
Otherwise, I'd rather "fix" the documentation to avoid code relying on
incompatible features, but I don't have a strong opinion if others think the GNU
runtime should deviate in this respect.

-- 
           Summary: [libobjc] Calling +initialize on a per category basis
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: libobjc
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot ayers at inode dot at
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: *-*-*
  GCC host triplet: *-*-*
GCC target triplet: *-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14382


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libobjc/14382] [libobjc] Calling +initialize on a per category basis
  2004-03-02 12:36 [Bug libobjc/14382] New: [libobjc] Calling +initialize on a per category basis d dot ayers at inode dot at
@ 2004-03-02 15:29 ` pinskia at gcc dot gnu dot org
  2004-03-02 15:49 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-02 15:29 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14382


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libobjc/14382] [libobjc] Calling +initialize on a per category basis
  2004-03-02 12:36 [Bug libobjc/14382] New: [libobjc] Calling +initialize on a per category basis d dot ayers at inode dot at
  2004-03-02 15:29 ` [Bug libobjc/14382] " pinskia at gcc dot gnu dot org
@ 2004-03-02 15:49 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-02 15:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-02 15:49 -------
Confirmed, here is a simple testcase:
#include <objc/objc.h>
#include <objc/Object.h>
int i = 0;
@interface A : Object
+initialize;
@end
@implementation A
+initialize
{
  printf("A\n");
  i++;
}
@end
@interface A(B)
+initialize;
@end
@implementation A(B)
+initialize
{
  printf("A(B)\n");
  i++;
}
@end
int main()
{
        A *b = [A new];
        if (i!=2)
          abort();
        return 0;
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-02 15:49:35
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14382


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-03-02 15:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-02 12:36 [Bug libobjc/14382] New: [libobjc] Calling +initialize on a per category basis d dot ayers at inode dot at
2004-03-02 15:29 ` [Bug libobjc/14382] " pinskia at gcc dot gnu dot org
2004-03-02 15:49 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).