FFI: Fix pointer difference operation on 64 bit platforms.

Thanks to cuiweixie. #1449
This commit is contained in:
Mike Pall 2026-03-27 19:47:27 +01:00
parent 89f268b3f7
commit b58b071895

View File

@ -118,7 +118,7 @@ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
/* All valid pointer differences on x64 are in (-2^47, +2^47), /* All valid pointer differences on x64 are in (-2^47, +2^47),
** which fits into a double without loss of precision. ** which fits into a double without loss of precision.
*/ */
setintptrV(L->top-1, (int32_t)diff); setintptrV(L->top-1, diff);
return 1; return 1;
} else if (mm == MM_lt) { /* Pointer comparison (unsigned). */ } else if (mm == MM_lt) { /* Pointer comparison (unsigned). */
setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2)); setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2));