From 0f8d1b92c37c80e96df2a157a78188d6d94b6e35 Mon Sep 17 00:00:00 2001 From: Maxime Dénès Date: Sun, 6 Sep 2015 21:09:48 +0200 Subject: Fix a bug in 31 bit arithmetic, leading to failing conversion tests. On 64 bits architectures, integers could have some of their 32 msb set to 1 internally in the VM. When read back to a Coq term, this was not observable. But an equality test would fail. From the user point of view, the symptom was that vm_compute; reflexivity would succeed but the subsequent Qed would fail. Bug reported by Tahina Ramananandro. --- kernel/byterun/coq_interp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kernel/byterun') diff --git a/kernel/byterun/coq_interp.c b/kernel/byterun/coq_interp.c index 4937af77f..399fa843f 100644 --- a/kernel/byterun/coq_interp.c +++ b/kernel/byterun/coq_interp.c @@ -1253,7 +1253,7 @@ value coq_interprete if (shiftby > 31) { if (shiftby < 62) { sp++; - accu = (value)((((*sp++)^1) << (shiftby - 31)) | 1); + accu = (value)(((((uint32_t)*sp++)^1) << (shiftby - 31)) | 1); } else { sp+=2; @@ -1262,7 +1262,7 @@ value coq_interprete } else{ /* *sp = 2*x+1 --> accu = 2^(shiftby+1)*x */ - accu = (value)(((*sp++)^1) << shiftby); + accu = (value)((((uint32_t)*sp++)^1) << shiftby); /* accu = 2^(shiftby+1)*x --> 2^(shifby+1)*x+2*y/2^(31-shiftby)+1 */ accu = (value)((accu | (((uint32_t)(*sp++)) >> (31-shiftby)))|1); } -- cgit v1.2.3