Skip to content

SEHException on misaligned access #91662

@EgorBo

Description

@EgorBo

Run the following code on an arm64 machine (e.g. Apple-M1):

using System.Runtime.CompilerServices;

long[] a = new long[100];
ref long misalignedLong = ref Unsafe.As<byte, long>(
    ref Unsafe.Add(ref Unsafe.As<long, byte>(ref a[0]), 1));
Test(ref misalignedLong);

[MethodImpl(MethodImplOptions.NoInlining)]
long Test(ref long misalignedLong) => Volatile.Read(ref misalignedLong);

Expected:

No exception or DataMisalignedException is thrown

Actual:

SEHException is thrown

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions