-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Calling instance-based methods with function pointers is not supported #110061
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Closing; wrong repro |
Reopened; updated repro |
Closing for now; the spec proposes "instance" keyword: unsafe class Instance {
void Use() {
delegate* instance<Instance, string> f = &ToString;
f(this);
}
} |
AFAIR LDM decided they're too nieche too expose in C#, but they should be fully functional in IL. I assume if they were to be exposed in C#, it'd only be |
Calling a managed function pointer on an instance that returns a non-primitive value type (perhaps based on length?) will return random values and causes stack\heap issues later.
UPDATED: I assume calling a function pointer on an instance method is supposed to work, provided the signature is correct for having the first parameter being the correct type (here "object" was used, but "TestClass" has the same result since it is a reference type). However, the function pointer spec says that instance methods are not supported (at least initially; not sure what transpired since then).
Note the IL looks correct, and the method is actually called.
This does not appear to be a regression.
Repro: the
long
property works butGuid
doesn't, and a subsequent call to thelong
property returns a corrupted value.The text was updated successfully, but these errors were encountered: