diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs index 43c098161607ed..cf7594163a406d 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/CrashInfo.cs @@ -172,7 +172,8 @@ private bool WriteExceptionHelper(ReadOnlySpan key, Exception exception, i if (!OpenValue(key, '{')) return false; - if (!WriteHexValue("address"u8, (ulong)Unsafe.AsPointer(ref exception))) + ulong address = Unsafe.As(ref exception); + if (!WriteHexValue("address"u8, address)) return false; if (!WriteHexValue("hr"u8, exception.HResult))