You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Building the following Objective-C code using using Automatic Reference Counting and the GNU Objective-C 2.0 runtime and -O1 or better optimization using Clang 14.0.5 causes an access violation at runtime.
This does not happen with Clang 13.0.1, or when using -O0, or when not using ARC.
Interestingly the access violation does not happen when using NSObject from GNUstep Base instead of the locally defined Test class, and it even works to call [Test new] after [NSObject new]. However calling [Test new]before[NSObject new] still reproduces the bug.
#import"objc/runtime.h"
#import<Foundation/Foundation.h>__attribute__((objc_root_class))
@interface Test {
id isa;
}
+ (id)new;
@end
@implementationTest
+ (id)new {
returnclass_createInstance(self, 0);
}
@end// does not crash:intmain(void) {
[NSObjectnew];
[Test new];
return0;
}
// crashes:/*int main(void) { [Test new]; [NSObject new]; return 0;}*/
I believe that this is caused by libobjc2 not having the ns_returns_retained attribute on class_createInstance. Closing and fixing it over there. Please reopen if this turns out to be a clang bug.
Building the following Objective-C code using using Automatic Reference Counting and the GNU Objective-C 2.0 runtime and
-O1
or better optimization using Clang 14.0.5 causes an access violation at runtime.This does not happen with Clang 13.0.1, or when using
-O0
, or when not using ARC.Building:
Result:
The text was updated successfully, but these errors were encountered: