Strange enough, I can't reproduce it either the way you describe. Not even with my usual build flags that I used to build diffutils which test suites fails and I saw that it uses gnulib that lead me here. If you can try to actually build and check diffutils (3.3) maybe you will be able to reproduce it as I have no idea if diffutils applies some custom configuration that may lead to the failure but is actually filtered somewhere in gnulib itself (which would be very strange). I will try to build diffutils from latest git checkout which will bootstrap gnulib to see how that goes.
But anyway, patch that uses #pragma attached. As I'm not entirely sure how this will actually work the patch may not be good enough - I do not know if it will filter "-Wformat-nonliteral" literally from the build flags or the interpretation of it, for an example, of what "-Wformat-security" is supposed to do. So, maybe additional pragmas, e.g. for "-Wformat", may be needed which will actually turn of all format warnings must be used (altough that may not be the best thing to do). If anyone can come up with better patch and fix the issue that would be great. Cheers! On Mon, Dec 2, 2013 at 7:40 PM, Paul Eggert <egg...@cs.ucla.edu> wrote: > On 12/02/2013 11:18 AM, Eric Blake wrote: > > So the correct fix is the use > > of #pragma GCC diagnostic to shut up the compiler's warning > > Another possibility is to use obscurer code that GCC > can't figure out; that's what we did for the empty-string > warning. > > I can't reproduce the problem on my > platform (Fedora 19 with its GCC 4.8.2). Here's how I > tried to reproduce it: > > ./gnulib-tool --create-testdir --dir foo xvasprintf > cd foo > ./configure CFLAGS='-Wformat -Werror=format-security -O2' > make > make check > >
diff --git a/tests/test-xvasprintf.c b/tests/test-xvasprintf.c index 453ca58..772a700 100644 --- a/tests/test-xvasprintf.c +++ b/tests/test-xvasprintf.c @@ -56,9 +56,12 @@ test_xvasprintf (void) { /* Silence gcc warning about zero-length format string. */ const char *empty = ""; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-zero-length" result = my_xasprintf (empty); ASSERT (result != NULL); ASSERT (strcmp (result, "") == 0); +#pragma GCC diagnostic pop free (result); } @@ -97,9 +100,12 @@ test_xasprintf (void) and about "format not a string literal and no format" (whatever that means) . */ const char *empty = ""; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" result = xasprintf (empty, empty); ASSERT (result != NULL); ASSERT (strcmp (result, "") == 0); +#pragma GCC diagnostic pop free (result); }