summaryrefslogtreecommitdiffstats
path: root/arith.c
diff options
context:
space:
mode:
Diffstat (limited to 'arith.c')
-rw-r--r--arith.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/arith.c b/arith.c
index c17ab743..a4a65ad7 100644
--- a/arith.c
+++ b/arith.c
@@ -2285,6 +2285,9 @@ static val comp_trunc(val a, val bits)
bn = c_num(bits);
+ if (bn < 0)
+ goto bad4;
+
switch (type(a)) {
case NUM:
an = c_num(a);
@@ -2311,6 +2314,9 @@ bad2:
bad3:
uw_throwf(error_s, lit("lognot: non-integral operand ~s"), a, nao);
+
+bad4:
+ uw_throwf(error_s, lit("lognot: negative bits value ~s"), bits, nao);
}
val lognot(val a, val bits)
@@ -2348,6 +2354,9 @@ val logtrunc(val a, val bits)
bn = c_num(bits);
+ if (bn < 0)
+ goto bad4;
+
switch (type(a)) {
case NUM:
an = c_num(a);
@@ -2374,6 +2383,9 @@ bad2:
bad3:
uw_throwf(error_s, lit("logtrunc: non-integral operand ~s"), a, nao);
+
+bad4:
+ uw_throwf(error_s, lit("logtrunc: negative bits value ~s"), bits, nao);
}
val sign_extend(val n, val nbits)