scc

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

commit fdf6ecca9cb0a8db49f2ac0590a941ac16750dd2
parent a4c970a99941637b75f5fc42b45e9d774aff6d7d
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 ||