[Bug libobjc/14382] New: [libobjc] Calling +initialize on a per category basis

d dot ayers at inode dot at gcc-bugzilla@gcc.gnu.org
Tue Mar 2 12:36:00 GMT 2004


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



More information about the Gcc-bugs mailing list