From 88fb0079cfabcba839b1f63f947910748db79b76 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Sat, 30 Aug 2025 13:39:04 +0000 Subject: [PATCH] libvex_ir.h: Clarify semantics of division and modulo operation. --- 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 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) -- 2.47.3