From: Florian Krohm Date: Sat, 30 Aug 2025 13:39:04 +0000 (+0000) Subject: libvex_ir.h: Clarify semantics of division and modulo operation. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=88fb0079cfabcba839b1f63f947910748db79b76;p=thirdparty%2Fvalgrind.git libvex_ir.h: Clarify semantics of division and modulo operation. --- diff --git a/VEX/pub/libvex_ir.h b/VEX/pub/libvex_ir.h index 750ba0701..8c68fab44 100644 --- a/VEX/pub/libvex_ir.h +++ b/VEX/pub/libvex_ir.h @@ -492,7 +492,13 @@ typedef Iop_CmpORD32S, Iop_CmpORD64S, /* Division */ - /* TODO: clarify semantics wrt rounding, negative values, whatever */ + /* Semantics of division as per C standard: + If the value of the divisor is zero, the behaviour is undefined. + When integers are divided, the result of division is the algebraic + quotient with any fractional part discarded. In other words: + truncation towards zero. If the quotient a/b is representable, + the expression (a/b)*b + a%b shall equal a; otherwise, the behaviour + of division and modulo operation is undefined. */ Iop_DivU32, // :: I32,I32 -> I32 (simple div, no mod) Iop_DivS32, // ditto, signed Iop_DivU64, // :: I64,I64 -> I64 (simple div, no mod)