On 10/26/2017 02:12 PM, Eric Gallager wrote:
On 10/26/17, Nathan Sidwell <nat...@acm.org> wrote:
On 10/26/2017 10:34 AM, David Malcolm wrote:
Possibly a silly question, but is it OK to have a formatted string
call in which some of the arguments aren't consumed? (here "col" is only
consumed for the true case, which consumes 2 arguments; it's not consumed
for the false case).
Yes.
I think I remember clang disagreeing; I remember it printing warnings
from -Wformat-extra-args in a similar situation in gnulib's
error_at_line module
C++ 21.10.1 defers to C. C-99 7.15.1 has no words saying va_arg must be
applied to exactly all arguments captured by va_list object. (and I'm
pretty sure scanf can bail early)
Now, it might be sensible to warn about:
printf ("", 5);
because printf's semantics are known. But that's not ill-formed, just
inefficient. And in this case we're doing the equivalent of:
printf (not-compile-time-constant, 5);
nathan
--
Nathan Sidwell