scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 56338bb08045561cdc17b33c9e9f4e5721807778
parent a926e8f5971ee8598fc7083ad9911da0c23fc76d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 17 Nov 2021 10:43:58 +0100

cc1: Fix validation of folded multiplication

The code was negating the minimum of the type but that
value was already negative in the case of integer and
float expressions.

Diffstat:
Msrc/cmd/cc/cc1/fold.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cmd/cc/cc1/fold.c b/src/cmd/cc/cc1/fold.c @@ -15,7 +15,7 @@ static int addi(TINT l, TINT r, Type *tp) { struct limits *lim = getlimits(tp); - TINT max = lim->max.i, min = -lim->min.i; + TINT max = lim->max.i, min = lim->min.i; if (l < 0 && r < 0 && l >= min - r || l == 0 || @@ -63,7 +63,7 @@ static int muli(TINT l, TINT r, Type *tp) { struct limits *lim = getlimits(tp); - TINT max = lim->max.i, min = -lim->min.i; + TINT max = lim->max.i, min = lim->min.i; if (l > -1 && l <= 1 || r > -1 && r <= 1 ||