diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-04 12:52:52 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-04 12:52:52 -0300 |
commit | ae9a0cbbb446499e759acae47664d1d136d7ba90 (patch) | |
tree | 856d7f11e6821a5527858e1430b2d57cc8f2152c | |
parent | d5212c13b081ed62d8e1ae436779e79c79edf564 (diff) | |
download | lua-ae9a0cbbb446499e759acae47664d1d136d7ba90.tar.gz lua-ae9a0cbbb446499e759acae47664d1d136d7ba90.tar.bz2 lua-ae9a0cbbb446499e759acae47664d1d136d7ba90.zip |
Bug: overlapping assignments
ISO C forbids assignment of a union field to another field of the same
union.
-rw-r--r-- | lcode.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -776,7 +776,8 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { | |||
776 | break; | 776 | break; |
777 | } | 777 | } |
778 | case VLOCAL: { /* already in a register */ | 778 | 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) */ | ||
780 | e->k = VNONRELOC; /* becomes a non-relocatable value */ | 781 | e->k = VNONRELOC; /* becomes a non-relocatable value */ |
781 | break; | 782 | break; |
782 | } | 783 | } |
@@ -1283,8 +1284,9 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | |||
1283 | if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ | 1284 | if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ |
1284 | luaK_exp2anyreg(fs, t); /* put it in a register */ | 1285 | luaK_exp2anyreg(fs, t); /* put it in a register */ |
1285 | if (t->k == VUPVAL) { | 1286 | if (t->k == VUPVAL) { |
1287 | int temp = t->u.info; /* upvalue index */ | ||
1286 | lua_assert(isKstr(fs, k)); | 1288 | 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) */ |
1288 | t->u.ind.idx = k->u.info; /* literal short string */ | 1290 | t->u.ind.idx = k->u.info; /* literal short string */ |
1289 | t->k = VINDEXUP; | 1291 | t->k = VINDEXUP; |
1290 | } | 1292 | } |