lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




Em ter., 18 de ago. de 2020 às 18:38, Philippe Verdy <verdyp@gmail.com> escreveu:
could this be related to
/* maximum length of the conversion of a number to a string */
#define MAXNUMBER2STR   50
where the string is allocated on the stack with an array of bytes whose size (including the null terminator) is not a multiple of the word size? Causing some internal bug in the stack slots allocator in GCC 10.1?
Note that "void luaO_tostring" is the only function where it is allocated this way. This may cause issue when this function is inlined (probably alignment problems).

May be this is solved by just making this a multiple of 8 bytes (64-bit architectures) or 16 bytes (128-bit architectures).
However how can even on a 64-bit architecture this generate a numeric string that could be 49 bytes long plus a null ?
May be the type for number can have its bitsize asserted to define the length that is needed for the mantissa, the exponent, the signs and the dot. If this is too complicate, why not just aligning 50 to the next multiple of 8 or 16, i.e. setting it to 56 or 64?
#define MAXNUMBER2STR   56
I agree. Could be 64.
This can avoid mistakes with address calcs, mainly with aggressive optimizations.
Everyone is power of two, it makes no sense to use decimal values, which are for humans, not machines.

regards,
Ranier Vilela