From 4d7469b610814d2ebb1e89aebebdeb68abfe7f4e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy <roberto@inf.puc-rio.br> Date: Mon, 7 Apr 2008 15:41:47 -0300 Subject: avoid constant folding for -0 (to avoid it colapsing to 0) --- lcode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lcode.c b/lcode.c index 96ef6b96..12a69362 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.34 2007/05/04 18:41:49 roberto Exp roberto $ +** $Id: lcode.c,v 2.35 2008/04/02 16:16:06 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -696,8 +696,8 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; switch (op) { case OPR_MINUS: { - if (isnumeral(e)) /* -constant? */ - e->u.nval = luai_numunm(NULL, e->u.nval); + if (isnumeral(e) && e->u.nval != 0) /* minus non-zero constant? */ + e->u.nval = luai_numunm(NULL, e->u.nval); /* fold it */ else { luaK_exp2anyreg(fs, e); codearith(fs, OP_UNM, e, &e2); -- cgit v1.2.3-55-g6feb