Do not require fixing a fixed field of a ref struct #9014
Replies: 13 comments
-
Encountered this problem multiple times while working with HW intrinsics. |
Beta Was this translation helpful? Give feedback.
-
This is very related to #1697 |
Beta Was this translation helpful? Give feedback.
-
Should this just be, don't requiring pinning when taking the address of a The entire |
Beta Was this translation helpful? Give feedback.
-
@tannergooding I think you’re right |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
-
It seems I've already proposed a more general question regarding all fields in #1564 |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
-
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
|
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Don't think that is a realistic option here. Code which is
Much better 😄 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
@jaredpar The issue has been closed without comment, converted into this discussion and #9015 has been opened then immediately locked. Could we get an update on the status of this proposal? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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.Beta Was this translation helpful? Give feedback.
All reactions