3 ms·
Is this really type safe? Does anything prevent the address of a member being taken, followed by an assignment to a member of different type (destroying the val
by gsg 13y ago
Is this really type safe? Does anything prevent the address of a member being taken, followed by an assignment to a member of different type (destroying the validity of the pointer)?
You can make tagged unions type safe if you eliminate storage that is interpreted in more than one way. You can do it by requiring immutability, introducing indirection, or by copying the type-variant part. Unless I'm missing something (very possible), this technique doesn't seem to do any of those things, so I don't see how it can be sound.