bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fw: Re: Re: tools-windows-msvc runtime error


From: loserist
Subject: Fw: Re: Re: tools-windows-msvc runtime error
Date: Sun, 16 Jul 2023 21:23:24 +0800 (GMT+08:00)

Hi all! I seem to have found the problem.the problem is that the user-defined class is not working properly, see the following code and its output message please.Does anyone know how to fix this?

#import <Foundation/Foundation.h>

@interface SayHello : NSObject

- (void)greet;

@end

@implementation SayHello

- (void)greet {

NSLog(@"Hello GnuStep");

}

@end

int main(int argc, char *argv[]) {

NSLog(@"arrayCls = %@", objc_getClass("NSArray")); // Yes

NSLog(@"stringCls = %@", objc_getClass("NSString")); // Yes


//! NSLog(@"userCls = %@", [SayHello class]); -- crash here!

NSLog(@"userCls = %@", objc_getClass("SayHello")); // null


NSArray *nameList = [NSArray arrayWithObjects:

@"Scott", @"Jesse", @"Gaia",

nil

];

NSLog(@"nameList = %@", nameList); // good

NSArray *nameList2 = [[NSArray alloc] init];

NSLog(@"nameList2 = %@", nameList2); // Ok


SayHello *userObj = [[SayHello alloc] init]; // crash here!

NSLog(@"userObj = %@", userObj);

return 0;

}

2023-07-16 21:02:02.665 abc[2996:4992] arrayCls = NSArray

2023-07-16 21:02:02.665 abc[2996:4992] stringCls = NSString

2023-07-16 21:02:02.665 abc[2996:4992] userCls = (null)

2023-07-16 21:02:02.665 abc[2996:4992] nameList = (Scott, Jesse, Gaia)

2023-07-16 21:02:02.665 abc[2996:4992] nameList2 = ()

Process 2380 stopped

* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ffb73b91048: Access violation reading locatio

n 0x00000000

frame #0: 0x00007ffb73b91048 objc.dll`objc_msgSend + 40

objc.dll`objc_msgSend:

-> 0x7ffb73b91048 <+40>: movl (%r10), %r11d

0x7ffb73b9104b <+43>: cmpl $0x8, %r11d

0x7ffb73b9104f <+47>: je 0x7ffb73b91063 ; <+67>

0x7ffb73b91051 <+49>: cmpl $0x0, %r11d



Thank you!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]