[cfe-commits] r140777 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/Sema/format-strings.c

David Blaikie dblaikie at gmail.com
Sat Oct 1 08:29:22 PDT 2011


>
> If I understand you correctly, are you saying that we should not worry too
> much that we don't catch 'printf("")' with my change because we can't know
> in general whether or not that's the right thing to warn about?  (with
> regards to empty format strings)
>

That was my thinking, yes. I figured this warning was more about mismatching
the number of arguments with the number of format specifiers.

Though now that I look at it the warning is unambiguously "format string is
empty" which does make me wonder whether your fix is the right one (& then
makes me wonder about the value of that warning - since it's clear that not
all functions that take format strings are no-ops on empty).

Is there a separate warning for a mismatched number of format specifiers?
(eg: printf("%d", 1, 2); ) That warning would catch the case you've now
limited the warn_empty_format_string too (granted, it'd catch other cases
too - that might be valid, I suppose people could have generic
infrastructure to insert format strings based on a set of available
arguments & sometimes they only use a subset of those arguments - but in
that case printf("", 1) is no more erroneous than printf("%d", 1, 2) so
catching the former in that more general warning makes sense to me, rather
than making a further special case for it)

- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111001/0ccbb69b/attachment.html>


More information about the cfe-commits mailing list