summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2017-10-11 13:12:17 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2017-10-11 13:12:17 -0700
commitaaefc7fe6b9e4302ae0a9353695e9680de083913 (patch)
tree934774e84ecea1409880938a2b25a5d5af2bc5f3
parent9e0807527850ff33152ff6b27c33cf609cd964a8 (diff)
downloadnasm-aaefc7fe6b9e4302ae0a9353695e9680de083913.tar.gz
BR 3392442: correct vmin in overflow_general()
The calculation of vmin in overflow_general() was bogus, causing silliness like ~80h being warned about in a byte context. Reported-by: C. Masloch <pushbx@38.de> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--include/nasmlib.h2
-rw-r--r--test/br3392442.asm6
2 files changed, 7 insertions, 1 deletions
diff --git a/include/nasmlib.h b/include/nasmlib.h
index 7af48964..79e866b5 100644
--- a/include/nasmlib.h
+++ b/include/nasmlib.h
@@ -461,7 +461,7 @@ static inline bool const_func overflow_general(int64_t value, int bytes)
sbit = (bytes << 3) - 1;
vmax = ((int64_t)2 << sbit) - 1;
- vmin = -((int64_t)1 << sbit);
+ vmin = -((int64_t)2 << sbit);
return value < vmin || value > vmax;
}
diff --git a/test/br3392442.asm b/test/br3392442.asm
new file mode 100644
index 00000000..e7a0511c
--- /dev/null
+++ b/test/br3392442.asm
@@ -0,0 +1,6 @@
+ ;; Bug report 3392442: invalid warning
+
+ and byte [0], ~80h
+ and byte [0], 0xfff
+ and byte [0], -256
+ and byte [0], -257