public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Frederic Stark <gsfred@almonde.com>
To: gnustep-dev@gnu.org, gcc@gcc.gnu.org
Subject: Problem implementing faults in Objective-C
Date: Tue, 21 Jun 2005 11:13:00 -0000	[thread overview]
Message-ID: <42B7F636.3030306@almonde.com> (raw)

Hi all,

I am sending this to gnustep-dev crossposted to gcc. Maybe this isn't 
the right mailing list. See at the end of the post for a 40 line program 
that exhibit the bad behavior.

Problem:
If a is a fault (ie: changes its isa pointer during forwardInvocation), 
then:

[a method1:[a method2]]

fails (a does not recognize 'method1:'), while:

id o = [a method2];
[a method1:o];

works.

The code works correctly under Mac OS X.

Am I doing something horribly wrong ?
This is on gcc 3.2/mingw

Thanks for any help,

--fred

fred@FLEA /c/Dev/ObjcInvocations
$ shared_obj/invocation.exe
This one works:
method1
This one fails:
: Uncaught exception NSInvalidArgumentException, reason: B(instance) 
does not recognize method1:

fred@FLEA /c/Dev/ObjcInvocations


$ gcc -v
Reading specs from 
c:/GNUstepVersions/1.10.0/MinGW/bin/../lib/gcc-lib/mingw32/3.2/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as 
--host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads 
--disable-nls --enable-languages=f77,c++,objc,ada 
--disable-win32-registry --disable-shared
Thread model: win32
gcc version 3.2 (mingw special 20020817-1)

$ uname -a
MINGW32_NT-5.0 FLEA 1.0.10(0.46/3/2) 2004-03-15 07:17 i686 unknown

makefile:

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

MAKEFILE_NAME = GNUstepMakefile

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = invocation

invocation_OBJC_FILES = Invocation.m

invocation_C_FILES =

invocation_CC_FILES =

invocation_HEADER_FILES =

invocation_OBJ_FILES =

ADDITIONAL_OBJCFLAGS =

ADDITIONAL_INCLUDE_DIRS = -I../SystemConfiguration

ADDITIONAL_LIB_DIRS = -L../SystemConfiguration

invocation_TOOL_LIBS = -lgnustep-base \
         -lobjc

-include GNUstepMakefile.preamble
-include GNUstepMakefile.local

include $(GNUSTEP_MAKEFILES)/tool.make

-include GNUstepMakefile.postamble

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

//	Test for invocation problem
#import <Foundation/Foundation.h>

@interface A : NSProxy
@end

@interface B : NSObject
- (void)method1:(id)o;
- (id)method2;
@end

@implementation A
- init { return self; }
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSel { return [B 
instanceMethodSignatureForSelector:aSel]; }
- (void)forwardInvocation:(NSInvocation *)anInvocation
{
	isa = [B class];
	[anInvocation invoke];
}
@end

@implementation B
- (id)method2 { return self; }
- (void)method1:(id)a { printf( "method1\n" ); }
@end

int main()
{
	[[NSAutoreleasePool alloc] init];
	B *theB0 = (B *)[[A alloc] init];
	B *theB1 = (B *)[[A alloc] init];

	printf( "This one works:\n" );

	id o = [theB0 method2];
	[theB0 method1:o];

	printf( "This one fails:\n" );
	fflush( stdout );

	[theB1 method1:[theB1 method2]];

	return 0;
}


             reply	other threads:[~2005-06-21 11:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-21 11:13 Frederic Stark [this message]
2005-06-21 16:49 ` Timothy J. Wood
2005-06-21 17:20   ` Frederic Stark
2005-06-21 17:48     ` Andrew Pinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42B7F636.3030306@almonde.com \
    --to=gsfred@almonde.com \
    --cc=gcc@gcc.gnu.org \
    --cc=gnustep-dev@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).