diff options
author | Maxime Dénès <mail@maximedenes.fr> | 2015-09-06 21:09:48 +0200 |
---|---|---|
committer | Maxime Dénès <mail@maximedenes.fr> | 2015-09-06 21:09:48 +0200 |
commit | 0f8d1b92c37c80e96df2a157a78188d6d94b6e35 (patch) | |
tree | 373c458574264f9ff9406adc25cf766d3413fdf0 /kernel/byterun | |
parent | a5e04d9dd178b2870b79776e1fbf1a858cdac49d (diff) |
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.
Diffstat (limited to 'kernel/byterun')
-rw-r--r-- | kernel/byterun/coq_interp.c | 4 |
1 files changed, 2 insertions, 2 deletions
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); } |