From: Florian K. <fk...@so...> - 2025-08-30 13:39:42
|
https://sourceware.org/cgit/valgrind/commit/?id=88fb0079cfabcba839b1f63f947910748db79b76 commit 88fb0079cfabcba839b1f63f947910748db79b76 Author: Florian Krohm <fl...@ei...> Date: Sat Aug 30 13:39:04 2025 +0000 libvex_ir.h: Clarify semantics of division and modulo operation. Diff: --- VEX/pub/libvex_ir.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/VEX/pub/libvex_ir.h b/VEX/pub/libvex_ir.h index 750ba07018..8c68fab441 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) |