tinyformat does compile time checks that catch that, for C++ anyway. At least if I'm not misunderstanding the bug.
Login to reply
Replies (2)
GCC does compile-time checks too, but they're both valid, and both print a string of the given width, but %*.s is weird and should probably elicit a warning. The man page suggests this will print padding (* specifies the minimum width, . specifies zero precision, so no chars from string are printed) and that the string need not be nul terminated, but it printed something and valgrind complained (string was *not* nul terminated), so I suspect the man page or implementation are wrong.
But it's really a "did you mean %*." warning because I expect no code deliberately does this...
Oh I thought you had a format string where you just wanted a literal. Null termination should still be handled by types (string vs span perhaps) rather than format spec, though i guess that's straying further from C.