mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
BUG: should copy the union, not (some of) its fields
This commit is contained in:
parent
e1dda047b2
commit
1ae0b6c0bf
2 changed files with 48 additions and 8 deletions
42
bugs
42
bugs
|
|
@ -797,3 +797,45 @@ patch = [[
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------
|
||||
-- Lua 5.1
|
||||
|
||||
Bug{
|
||||
what = [[In 16-bit machines, expressions and/or with numeric constants as the
|
||||
right operand may result in weird values]],
|
||||
|
||||
report = [[Andreas Stenius, 15/03/2006]],
|
||||
|
||||
example = [[
|
||||
print(false or 0) -- on 16-bit machines
|
||||
]],
|
||||
|
||||
patch = [[
|
||||
* lcode.c:
|
||||
@@ -731,17 +731,15 @@
|
||||
case OPR_AND: {
|
||||
lua_assert(e1->t == NO_JUMP); /* list must be closed */
|
||||
luaK_dischargevars(fs, e2);
|
||||
- luaK_concat(fs, &e1->f, e2->f);
|
||||
- e1->k = e2->k; e1->u.s.info = e2->u.s.info;
|
||||
- e1->u.s.aux = e2->u.s.aux; e1->t = e2->t;
|
||||
+ luaK_concat(fs, &e2->f, e1->f);
|
||||
+ *e1 = *e2;
|
||||
break;
|
||||
}
|
||||
case OPR_OR: {
|
||||
lua_assert(e1->f == NO_JUMP); /* list must be closed */
|
||||
luaK_dischargevars(fs, e2);
|
||||
- luaK_concat(fs, &e1->t, e2->t);
|
||||
- e1->k = e2->k; e1->u.s.info = e2->u.s.info;
|
||||
- e1->u.s.aux = e2->u.s.aux; e1->f = e2->f;
|
||||
+ luaK_concat(fs, &e2->t, e1->t);
|
||||
+ *e1 = *e2;
|
||||
break;
|
||||
}
|
||||
]],
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
14
lcode.c
14
lcode.c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lcode.c,v 2.23 2005/11/25 13:29:32 roberto Exp roberto $
|
||||
** $Id: lcode.c,v 2.24 2005/12/22 16:19:56 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
|
@ -731,17 +731,15 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
|
|||
case OPR_AND: {
|
||||
lua_assert(e1->t == NO_JUMP); /* list must be closed */
|
||||
luaK_dischargevars(fs, e2);
|
||||
luaK_concat(fs, &e1->f, e2->f);
|
||||
e1->k = e2->k; e1->u.s.info = e2->u.s.info;
|
||||
e1->u.s.aux = e2->u.s.aux; e1->t = e2->t;
|
||||
luaK_concat(fs, &e2->f, e1->f);
|
||||
*e1 = *e2;
|
||||
break;
|
||||
}
|
||||
case OPR_OR: {
|
||||
lua_assert(e1->f == NO_JUMP); /* list must be closed */
|
||||
luaK_dischargevars(fs, e2);
|
||||
luaK_concat(fs, &e1->t, e2->t);
|
||||
e1->k = e2->k; e1->u.s.info = e2->u.s.info;
|
||||
e1->u.s.aux = e2->u.s.aux; e1->f = e2->f;
|
||||
luaK_concat(fs, &e2->t, e1->t);
|
||||
*e1 = *e2;
|
||||
break;
|
||||
}
|
||||
case OPR_CONCAT: {
|
||||
|
|
@ -750,7 +748,7 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
|
|||
lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
|
||||
freeexp(fs, e1);
|
||||
SETARG_B(getcode(fs, e2), e1->u.s.info);
|
||||
e1->k = e2->k; e1->u.s.info = e2->u.s.info;
|
||||
e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
|
||||
}
|
||||
else {
|
||||
luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue