If it does, what, if anything, does it do differently from -Wformat?
It's borrowed from GCC, as it is designed to be a suitable drop in replacement. GCC's description:
-Wformat=2
Enable -Wformat plus format checks not included in -Wformat. Currently
equivalent to `-Wformat -Wformat-nonliteral -Wformat-security
-Wformat-y2k'.
That answers most of your questions.
Does this do anything at all?
Yes. The following program emits different warnings, depending on the presence (or absence) of -Wformat=2
:
__attribute__((__format__ (__printf__, 1, 2)))
static void F(const char* const pString, ...) {
}
int main(int argc, const char* argv[]) {
F("", 0);
F(argv[0], 0);
const char str[] = "aaa";
F(str, 0);
F("%i", 0);
F("%i");
return 0;
}
Note: It appears Clang rolls -Wformat-security
into -Wformat
.
Finally, I've not tested -Wformat-y2k
, but it is defined by GCC as:
-Wformat-y2k
If -Wformat is specified, also warn about strftime formats which may yield only a two-digit year.