4 ms·
In this case aliasing refers to memory aliasing. As in, given a common struct that represents a type union, you can overlap the fields that satisfy 'unmanaged'
by neonsunset 2y ago
In this case aliasing refers to memory aliasing. As in, given a common struct that represents a type union, you can overlap the fields that satisfy 'unmanaged' constraint (think int, MyStruct(short, long), Guid) between each other, but you cannot overlap them with fields that are or contain object references, because this violates the spec and GC will likely crash upon encountering data that turns into garbage when interpreted as a pointer.
- kkukshtel 2y agoAn official proposal was just submitted for type unions: https://github.com/dotnet/csharplang/blob/18a527bcc1f0bdaf542d8b9a189c50068615b439/proposals/TypeUnions.md https://github.com/dotnet/csharplang/blob/18a527bcc1f0bdaf54...