Skip to content

A ref T field where T is unmanaged is itself treated as unmanaged #62528

@DaZombieKiller

Description

@DaZombieKiller

Tested with a daily SDK build (7.0.100-preview.7.22358.13):

unsafe
{
    var byref = default(ByReference<int>);
    var byptr = &byref; // does not error
}

readonly ref struct ByReference<T>
{
    public readonly ref T Value;
}

Expected Behavior:
error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('ByReference<int>')

Actual Behavior:
The code compiles successfully.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions