commit f947fc1eb5ba24ad77b5a60c946e247fa72733cf
parent 0d514bbdaf782b79e4cae239baba336aacd35876
Author: Bor Grošelj Simić <bgs@turminal.net>
Date: Tue, 28 Feb 2023 16:55:00 +0100
prevent negation of INTMAX_MIN
-INTMAX_MIN is UB, but -(uintmax_t)INTMAX_MIN isn't
Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/eval.c b/src/eval.c
@@ -998,7 +998,7 @@ eval_unarithm(struct context *ctx, struct expression *in, struct expression *out
if (type_is_float(out->result)) {
out->constant.fval = -lvalue.constant.fval;
} else {
- out->constant.ival = -lvalue.constant.ival;
+ out->constant.ival = -(uintmax_t)lvalue.constant.ival;
}
break;
case UN_PLUS: