Here is my code:
void autoreleasingReturn (NSError * __autoreleasing *error)
{
// --- Crashing
*error = [[NSError alloc] init];
// --- Not crashing
// *error = [NSError errorWithDomain:@"hello"
// code:-1
// userInfo:@{}];
}
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSError __strong *error = nil;
autoreleasingReturn(&error);
NSLog(@"error: %@", error); // crash!
}
return 0;
}
Traces (sorry, can not copy-paste):
The question is: what is going on?
I need details on what is going on in this code. Really interesting... Instruments don't show any leaks, zombies etc.