Optimization changes behaviour of AutoreleasingUnsafeMutablePointer<Pointee>

Hi there,


We faced an issue which has to do with AutoreleasingUnsafeMutablePointer<Pointee> not keeping the value of a set objet.


We use the cited struct, pointee property, to store some values. Depending on the logic, sometimes the value to store is a NSNull, because it is the output of a casting.


After updating to Xcode 11.4 we've notices that depending on the optimization process triggered when compiling, that value is stored or not. E.g.:

- -Onone => this mode makes NSNull value not kept, making the value of the pointee property nil.

- -O => this mode makes the pointee property to hold NSNull value.


We were wondering whether that implementation change in the behaviour of the struct AutoreleasingUnsafeMutablePointer is right and something on purpuse, depending on the optimization mode used when it comes to compile.


Definitely, prior to Xcode 11.4 the described behaviour didn't occur, where AutoreleasingUnsafeMutablePointer.pointee always held NSNull value, regardless of the optimization mode.


I hope someone can bring some clarification here.


Thanks in advance!


Manuel

Replies

Could you share a small reproducer that illustrates the issue?