lua-users home
lua-l archive

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


On 27/08/2021 16.28, Roberto Ierusalimschy wrote:
Thanks for the report. Do you have any real case where this is causing
problems? (e.g., a platform with a weird behavior for these uses, a tool
that complains about Lua source code.)

For reference, the standard *explicitly* says "behavior is undefined"
and not just unspecified, but I tried both gcc and clang in gnu99 and
C11 modes with -fsanitize=undefined and neither of them produced any
warnings when formatting "%02c" or "%#02.4c" and other nonsense.  (That
said, as far as I understand UBSAN isn't supposed to catch _everything_,
just a subset of all undefined stuff.)

And from testing them on my machine, string.format("%02c",string.byte"1") results in "01", so it isn't ignored.

On my machine, "%02c" produces " 1" so while it seems to be not truly
undefined "in practice", at least the behavior can't be relied on.

Cheers!
-- nobody