diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-12 15:56:13 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-12 15:56:13 -0300 |
| commit | d51022bf9e496ae4a7276b600d2755becc7d4323 (patch) | |
| tree | 4a31a82096c7076ffafd4f25ae8dbc806bcae372 | |
| parent | bb7bb5944c9b3c868c6ab9cbe7d11b611251066b (diff) | |
| download | lua-d51022bf9e496ae4a7276b600d2755becc7d4323.tar.gz lua-d51022bf9e496ae4a7276b600d2755becc7d4323.tar.bz2 lua-d51022bf9e496ae4a7276b600d2755becc7d4323.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 | } |
