lua

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

commit d51022bf9e496ae4a7276b600d2755becc7d4323
parent bb7bb5944c9b3c868c6ab9cbe7d11b611251066b
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Wed, 12 Jun 2024 15:55:46 -0300

Bug: overlapping assignments

ISO C forbids assignment of a union field to another field of the same
union.

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

diff --git a/lcode.c b/lcode.c @@ -776,7 +776,8 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { break; } case VLOCAL: { /* already in a register */ - e->u.info = e->u.var.ridx; + int temp = e->u.var.ridx; + e->u.info = temp; /* (can't do a direct assignment; values overlap) */ e->k = VNONRELOC; /* becomes a non-relocatable value */ break; } @@ -1283,8 +1284,9 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ luaK_exp2anyreg(fs, t); /* put it in a register */ if (t->k == VUPVAL) { + int temp = t->u.info; /* upvalue index */ lua_assert(isKstr(fs, k)); - t->u.ind.t = t->u.info; /* upvalue index */ + t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */ t->u.ind.idx = k->u.info; /* literal short string */ t->k = VINDEXUP; }