lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 4d7469b610814d2ebb1e89aebebdeb68abfe7f4e
parent 2b84e36b93841cac5b1d43cb7ec7324840f4fd59
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon,  7 Apr 2008 15:41:24 -0300

avoid constant folding for -0 (to avoid it colapsing to 0)

Diffstat:
Mlcode.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 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);