Monday, June 2, 2025

Separate Expressions for +alloc and -init

Ronald Oussoren:

The following code will crash hard when compiled using ARC:

#import <Foundation/Foundation.h>

int main(void)
{
     NSOutputStream* stream;

      stream = [NSOutputStream alloc];
      stream = [stream initToMemory];

      NSLog(@"%@", stream);
}

This is split calls to alloc and initToMemory are effectively what happens when using NSOutputStream.alloc().initToMemory() in Python.

[…]

This appears to be a genuine bug in macOS, filed as FB17759654.

Comments RSS · Twitter · Mastodon

Leave a Comment