Summary
I mentioned the following in #21788:
In Objective-C, an -init… method should always be called immediately after +alloc. Calling any other instance method on an object you just allocated before calling -init… is undefined behavior.123
I believe that each tp_new callback should only call tp_alloc and not instantiate an uninitialized Objective-C object. Each tp_init callback should then create a fully initialized Objective-C object via an +alloc/-init… pair.
I'm starting work on #31797 and the use of unpaired +alloc/-init… calls is generating a few warnings. I'd like to clean this up at the same time I do the ARC work.
Proposed fix
No response
Summary
I mentioned the following in #21788:
I'm starting work on #31797 and the use of unpaired
+alloc/-init…calls is generating a few warnings. I'd like to clean this up at the same time I do the ARC work.Proposed fix
No response
Footnotes
"But the resulting object is not yet usable." from Object Allocation ↩
"You must use an init... method to complete the initialization process." from +alloc ↩
"immediately" and "An init message is coupled with an alloc … message in the same line of code" from -init ↩