From b13234e198549fc9a31fe0012d94845d66156c8c Mon Sep 17 00:00:00 2001 From: "Aman Khalid (from Dev Box)" Date: Tue, 5 Aug 2025 16:02:26 -0400 Subject: [PATCH 1/2] Fix RISC-V emitter build --- src/coreclr/jit/emitriscv64.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/emitriscv64.cpp b/src/coreclr/jit/emitriscv64.cpp index 790feafff0f926..5f66076edbd3c1 100644 --- a/src/coreclr/jit/emitriscv64.cpp +++ b/src/coreclr/jit/emitriscv64.cpp @@ -1895,7 +1895,8 @@ unsigned emitter::emitOutputCall(const insGroup* ig, BYTE* dst, instrDesc* id) } } - return dst - origDst; + assert(dst > origDst); + return (unsigned)(dst - origDst); } void emitter::emitJumpDistBind() From df0774544fbc09df236d80b60e99a35f9648b864 Mon Sep 17 00:00:00 2001 From: "Aman Khalid (from Dev Box)" Date: Tue, 5 Aug 2025 16:05:53 -0400 Subject: [PATCH 2/2] Add another assert --- src/coreclr/jit/emitriscv64.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/jit/emitriscv64.cpp b/src/coreclr/jit/emitriscv64.cpp index 5f66076edbd3c1..5fcb77df9a4efe 100644 --- a/src/coreclr/jit/emitriscv64.cpp +++ b/src/coreclr/jit/emitriscv64.cpp @@ -1896,6 +1896,7 @@ unsigned emitter::emitOutputCall(const insGroup* ig, BYTE* dst, instrDesc* id) } assert(dst > origDst); + assert((dst - origDst) <= UINT_MAX); return (unsigned)(dst - origDst); }