[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How does string.format handle undefined behavior?
- From: Halalaluyafail3 <luigighiron@...>
- Date: Fri, 27 Aug 2021 10:34:33 -0400
No, I just noticed it while reading the definition of the fprintf
function. Most platforms will probably handle them fine, but the
results may vary between the platforms (I've only tested the results
on my machine). They should probably be ignored or generate an error
in string.format, but accepting them is probably ok for all
On Fri, Aug 27, 2021 at 10:29 AM Roberto Ierusalimschy
> > Yes, and I've found a few places where it accepts strings which cause
> > undefined behavior:
> > If precision is specified for conversion specifiers other than d, i,
> > o, u, x, X, a, A, e, E, f, F, g, G, and s.
> > If the '#' flag is specified for conversion specifiers other than o,
> > x, X, a, A, e, E, f, F, g, and G.
> > If the '0' flag is specified for conversion specifiers other than d,
> > i, o, x, X, a, A, e, E, f, F, g, and G.
> > And from testing them on my machine,
> > string.format("%02c",string.byte"1") results in "01", so it isn't
> > ignored.
> 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.)
> -- Roberto