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 ObjC?


Hi,

  I think that I have discovered a bug in Objective-C.
The following program runs with the egcs-1.1.1 compiler
but generates a core dump if I compile it with egcs-1.1.2
und Linux 2.2. It seems that the forward-mechanism has
problems with arguments. The programm should generate
the output

method of A
method of A

The first output stems from a method-call via the forward-
method WITHOUT any arguments whereas the second output
stems from a method-call via the forward-method WITH an
argument. With egcs-1.1.1 I get both lines of output but
with the egcs-1.1.2 the program crashes during the second
method method call.

Ciao
  Axel



---------------------------------------------------------

#include <objc/Object.h>
#include <stdio.h>

@interface A : Object {
}
- methodOfA;
- otherMethodOfA: object;
@end

@interface B : Object {
}
@end

@implementation A 
- methodOfA {
  printf("method of A\n");
  return self;
}
- otherMethodOfA: object {
  return [object methodOfA];
}
@end

@implementation B
- (retval_t)forward :(SEL)aSelector :(arglist_t)argFrame {
  A *anA = [A new];

  if ( [anA respondsTo:aSelector]) 
    return [ anA performv: aSelector: argFrame];
  else
    printf("Unknown\n");
  return nil;
}      

@end

int main() {

  [ [B new] methodOfA ];
  [ [B new] otherMethodOfA: [A new] ];

  return 1;
}

-- 
Sent through Global Message Exchange - http://www.gmx.net


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