Array.cs uses Unsafe.As to cast arrays to other array types which is UB in case types don't match, it should be changed to casting the ref returned from GetArrayDataReference instead:
|
ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<int[]>(array)), endIndex), |
|
ref Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(Unsafe.As<long[]>(array)), endIndex), |