Visitar URL original
Bug: overlapping assignments · lua/lua@ae9a0cb · GitHub
Skip to content

Commit ae9a0cb

Browse files
committed
Bug: overlapping assignments
ISO C forbids assignment of a union field to another field of the same union.
1 parent d5212c1 commit ae9a0cb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎lcode.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,8 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
776776
break;
777777
}
778778
case VLOCAL: { /* already in a register */
779-
e->u.info = e->u.var.ridx;
779+
int temp = e->u.var.ridx;
780+
e->u.info = temp; /* (can't do a direct assignment; values overlap) */
780781
e->k = VNONRELOC; /* becomes a non-relocatable value */
781782
break;
782783
}
@@ -1283,8 +1284,9 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
12831284
if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */
12841285
luaK_exp2anyreg(fs, t); /* put it in a register */
12851286
if (t->k == VUPVAL) {
1287+
int temp = t->u.info; /* upvalue index */
12861288
lua_assert(isKstr(fs, k));
1287-
t->u.ind.t = t->u.info; /* upvalue index */
1289+
t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */
12881290
t->u.ind.idx = k->u.info; /* literal short string */
12891291
t->k = VINDEXUP;
12901292
}

0 commit comments

Comments
 (0)