Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New issue Request: Make generic types with explicit layout a compiler error #832

Open
AdamSpeight2008 opened this issue Feb 8, 2016 · 0 comments
Labels
Feature Request help wanted The issue is up-for-grabs, and can be claimed by commenting
Milestone

Comments

@AdamSpeight2008
Copy link

Originally posted by @leppie (here)


The following compiles, but results in a TypeLoadException:

[StructLayout(LayoutKind.Explicit)]
struct Union<T1, T2>
{
    [FieldOffset(0)]
    readonly T1 t1;
    [FieldOffset(0)]
    readonly T2 t2;
}

Could not load type 'Union2' ...because generic types cannot have explicit layout.`
Given it will always fail at runtime, should this not be considered to be a compiler error instead?


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request help wanted The issue is up-for-grabs, and can be claimed by commenting
Projects
None yet
Development

No branches or pull requests

4 participants