summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bugs42
-rw-r--r--lcode.c14
2 files changed, 48 insertions, 8 deletions
diff --git a/bugs b/bugs
index 27bf71d0..e9ea6b73 100644
--- a/bugs
+++ b/bugs
@@ -797,3 +797,45 @@ patch = [[
797 797
798} 798}
799 799
800
801
802-----------------------------------------------------------------
803-- Lua 5.1
804
805Bug{
806what = [[In 16-bit machines, expressions and/or with numeric constants as the
807right operand may result in weird values]],
808
809report = [[Andreas Stenius, 15/03/2006]],
810
811example = [[
812print(false or 0) -- on 16-bit machines
813]],
814
815patch = [[
816* lcode.c:
817@@ -731,17 +731,15 @@
818 case OPR_AND: {
819 lua_assert(e1->t == NO_JUMP); /* list must be closed */
820 luaK_dischargevars(fs, e2);
821- luaK_concat(fs, &e1->f, e2->f);
822- e1->k = e2->k; e1->u.s.info = e2->u.s.info;
823- e1->u.s.aux = e2->u.s.aux; e1->t = e2->t;
824+ luaK_concat(fs, &e2->f, e1->f);
825+ *e1 = *e2;
826 break;
827 }
828 case OPR_OR: {
829 lua_assert(e1->f == NO_JUMP); /* list must be closed */
830 luaK_dischargevars(fs, e2);
831- luaK_concat(fs, &e1->t, e2->t);
832- e1->k = e2->k; e1->u.s.info = e2->u.s.info;
833- e1->u.s.aux = e2->u.s.aux; e1->f = e2->f;
834+ luaK_concat(fs, &e2->t, e1->t);
835+ *e1 = *e2;
836 break;
837 }
838]],
839
840}
841
diff --git a/lcode.c b/lcode.c
index feaad660..b8ba2a98 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.23 2005/11/25 13:29:32 roberto Exp roberto $ 2** $Id: lcode.c,v 2.24 2005/12/22 16:19:56 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -731,17 +731,15 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
731 case OPR_AND: { 731 case OPR_AND: {
732 lua_assert(e1->t == NO_JUMP); /* list must be closed */ 732 lua_assert(e1->t == NO_JUMP); /* list must be closed */
733 luaK_dischargevars(fs, e2); 733 luaK_dischargevars(fs, e2);
734 luaK_concat(fs, &e1->f, e2->f); 734 luaK_concat(fs, &e2->f, e1->f);
735 e1->k = e2->k; e1->u.s.info = e2->u.s.info; 735 *e1 = *e2;
736 e1->u.s.aux = e2->u.s.aux; e1->t = e2->t;
737 break; 736 break;
738 } 737 }
739 case OPR_OR: { 738 case OPR_OR: {
740 lua_assert(e1->f == NO_JUMP); /* list must be closed */ 739 lua_assert(e1->f == NO_JUMP); /* list must be closed */
741 luaK_dischargevars(fs, e2); 740 luaK_dischargevars(fs, e2);
742 luaK_concat(fs, &e1->t, e2->t); 741 luaK_concat(fs, &e2->t, e1->t);
743 e1->k = e2->k; e1->u.s.info = e2->u.s.info; 742 *e1 = *e2;
744 e1->u.s.aux = e2->u.s.aux; e1->f = e2->f;
745 break; 743 break;
746 } 744 }
747 case OPR_CONCAT: { 745 case OPR_CONCAT: {
@@ -750,7 +748,7 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
750 lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); 748 lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
751 freeexp(fs, e1); 749 freeexp(fs, e1);
752 SETARG_B(getcode(fs, e2), e1->u.s.info); 750 SETARG_B(getcode(fs, e2), e1->u.s.info);
753 e1->k = e2->k; e1->u.s.info = e2->u.s.info; 751 e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
754 } 752 }
755 else { 753 else {
756 luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ 754 luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */