[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.4.0 (rc3) now available
- From: Hugo Musso Gualandi <hgualandi@...>
- Date: Sat, 09 May 2020 15:03:19 -0300
Hi,
GCC 10 just came out and its -Wstringop-overflow warning is pickier
than it used to be. Attached to this message is the warning that I get
when compiling 5.4-rc3 using GCC 10.0.1.
The culprit seems to be the getstr macro in lobject.h. It appears that
GCC doesn't like that the string bytes are after the struct and would
prefer if the byte array were a member of the struct:
typedef struct TString {
CommonHeader;
lu_byte extra;
lu_byte shrlen;
unsigned int hash;
union {
size_t lnglen;
struct TString *hnext;
} u;
char bytes[1];
} TString;
#define getstr(ts) check_exp(sizeof((ts)->extra), ts->bytes)
#define sizelstring(l) (sizeof(TString) + (l) * sizeof(char))
-- Hugo
In function ‘createstrobj’,
inlined from ‘luaS_createlngstrobj’ at lstring.c:170:17,
inlined from ‘luaS_newlstr’ at lstring.c:240:10:
lstring.c:164:17: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
164 | getstr(ts)[l] = '\0'; /* ending 0 */
In file included from ldebug.h:11,
from lstring.c:17:
lstring.c: In function ‘luaS_newlstr’:
lstate.h:315:18: note: at offset 0 to object ‘ts’ with size 24 declared here
315 | struct TString ts;
| ^~
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org