-
Couldn't load subscription status.
- Fork 5.2k
Minimize use of unsafe context
#111025
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
Minimize use of unsafe context
#111025
Conversation
|
I'm not a fan of this change, these types are very unsafe-adjacent so I don't see why repeating the keyword 7 times is beneficial. |
|
This change brings these files into alignment with runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs Line 33 in dc0432b
|
|
I agree with @MihaZupan, but since there is already an inconsistency with V128 I guess it's fine to clean up? PS: it is really unfortunate that |
|
Looking at |
when I was removing redundant unsafe I didn't scan SIMD APIs so I can imagine there are some redundancies there |
I agree with this. As we move forward with refining exactly what "unsafe" means and adding to what triggers warnings and viral requirements, we should also look at removing things that are no longer appropriate. |
It also produces a compiler warning, which we suppress for the repository: |
| static unsafe Vector128<T> ISimdVector<Vector128<T>, T>.LoadAlignedNonTemporal(T* source) => Vector128.LoadAlignedNonTemporal(source); | ||
|
|
||
| /// <inheritdoc cref="ISimdVector{TSelf, T}.LoadUnsafe(ref readonly T)" /> | ||
| [Intrinsic] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overloads that take ref T should be really marked as unsafe too, even though C# does not require it today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding it there is a bit unnecessary since it doesn't actually do anything. I think what we really want is [UnsafeCallersOnly] instead, so that callers must use unsafe { } to invoke the method.
|
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics |
I think we should likely close this PR until a desired approach is determined. The inconsistency isn't hurting anything and we don't have a definitive plan, so its effectively unnecessary churn. I'd like to determine if we have concrete plans on pushing something like We then should make a separate determination on the coding style usage of After we decide the outcome of these points, then we can start submitting PRs that do such cleanup/normalization. CC. @stephentoub, @jkotas |
Closing, blocked by: |
Contributes to #94941.
Follow-up to #110953.
cc: @EgorBo