This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug in gcc/egcs objc support.



I have discovered a bug in the support for Protocols in gcc-2.8.1 and egcs.
I wonder if it is a known problem or not?

If you refer to a protocol using the '@protocol(...)' syntax, but none of the
classes in your application actually conform to the protocol, then the Protocol
object returned by @protocol(...) is not correctly initialised, so your program
will crash when you try to send a message to it.

Now most applications are not going to want to use a protocol that none of the
classes in the application conform to - but with distributed objects, it's
common to use a protocol that a class in a remote application conforms to, in
order to check what methods you can send to an object in the remote app.

Of course, as a workaround, you can create a dummy class in your application
that conforms to the protocol and ignore the compiler warnings when you don't
actually implement the protocol methods in the class - but that's ugly.

As far as I can see, the @protocol() directive should cause the compiler to add
the referenced protocol to the list of static objects in the symbol table and
the runtime should then use that list of statics to make sure the protocol
object is initialised.  Unfortunately, I don't understand the gcc internals
well enough to be sure about this (or to know exactly how to get the compiler
to do this).  Anybody else know how?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]