ソースを参照

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

Roberto Ierusalimschy 17 年 前
コミット
4d7469b610
1 ファイル変更3 行追加3 行削除
  1. 3 3
      lcode.c

+ 3 - 3
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);