Reading uninitialized¹ memory (via pointee
or load
or any other mechanism) is undefined behavior.
This should be clarified, but the correct interpretation is as follows:
- When reading, the pointed-to instance must already be initialized.
- When assigning, the pointed-to instance must either already be initialized or be trivial.
¹ what exactly qualifies as "initialization" here is quite subtle, because we have to allow for memory initialized by non-Swift code that doesn't have the same notion of "initialization" as Swift. "Must either be initialized in the Swift sense or contain a valid value of compatible type" is probably close enough if we wave our hands a little bit.