-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Do not require fixing a fixed field of a ref struct #1792
Comments
Encountered this problem multiple times while working with HW intrinsics. |
This is very related to #1697 |
Should this just be, don't requiring pinning when taking the address of a The entire |
@tannergooding I think you’re right |
@tannergooding I didn't talk about fields in #1697 but I probably should have. I think it should be safe to take both the address of the |
It seems I've already proposed a more general question regarding all fields in #1564 |
@gafter, does this need to go to LDM or is it already covered by the languge spec? The fix, overall, looks rather trivial. From what I was able to determine, this ultimately comes down to what we return from |
I guess this does need to go to LDM, since it could be a breaking change... Normally, the compiler reports If this was simply changed to not require
|
I've prototyped something that looks to work here: tannergooding/roslyn@f31dbcd It goes with the first option (which is most likely not what LDM will decide given the compat bar) and I'm sure I missed some edge cases, but I'll add more tests to find out. |
I think this solution along with adding a warning to a warning wave might be the best solution to add this without breaking compatibility. (An error would be ideal, but LDM decided against error waves.) That and also probably omit pinned flag on the corresponding local when the unnecessary fixed statement is used. |
Don't think that is a realistic option here. Code which is
Much better 😄 |
Just commenting here as I always need to go looking for it again. The LDM last reviewed this here: https://github.com/dotnet/csharplang/blob/master/meetings/2020/LDM-2020-10-14.md#do-not-require-fixing-a-fixed-field-of-a-ref-struct and its on the long term backlog |
From #1502
A fixed statement should not be required on a fixed field of a ref struct, because it is never moveable.
Note for future LDM consideration: there is a bug tail involved with any
fixed
change. While this is probably not worth it on it's own merits, if we have otherfixed
work that result in refactoring this would be worth it at that point.The text was updated successfully, but these errors were encountered: