Skip to content
Discussion options

You must be logged in to vote

However, expressing this currently requires unsafe code because StoreAligned() takes a pointer.

The ref overload would require unsafe too, it's no any safer than the unmanaged pointer variant (in fact, it's actually more unsafe). In .NET 11/12, All Loads/Stores accepting ref in SIMD already annotated as "requires unsafe context to call".

Or is there some other reason why an aligned store cannot or should not be exposed using a managed byref?

GC has pointer-sized alignment, so there is no way you can get 16 byte alignment for ref unless:

  1. You pin it using fixed and manually align. Any attempt to align it without pinning may lead to silent change in alignment by GC (it can iterrupt at a…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by tannergooding
Comment options

You must be logged in to vote
1 reply
@EgorBo
Comment options

EgorBo Sep 9, 2026
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants