"format not a string literal"

Ken Raeburn raeburn@raeburn.org
Wed Oct 13 23:16:00 GMT 1999


Ulrich Drepper <drepper@cygnus.com> writes:
> Because you haven't used the right sources, headers, or options.  The
> gettext calls in GNU gettext code actually expands into an statement
> expression.  Like this (I cleaned it up):

Well, right.  Currently gcc can do no checking when the format is a
computed expression.  That's what the warning is telling you.  If
you're using gettext, and compiling with -Wformat or -Wall, and you
think the compiler has verified that your printf formats all match
their arguments, you're just wrong.

Current versions of gcc can retain the __builtin_constant_p test
inside an inline function.  If you change gettext to be an inline
function (at least for gcc 2.96 and later), you'll get the format
checking back and this warning should go away (since the compiler
knows about a function named "gettext" but not a macro by that name),
and you shouldn't lose any of the performance.

Otherwise, we should probably make sure that people know that -Wformat
is useless when GNU gettext is involved.  I certainly wouldn't have
guessed that that was the case, and I'd consider it a bug -- not
necessarily a bug in gettext, but a bug that's far, far easier to
address by tweaking gettext.

For the sake of systems with glibc already out there, I suppose we
have to add another option, and leave it turned off by default.  But I
still think gettext should be changed, so that the option can be used
with code that calls gettext.


More information about the Gcc-bugs mailing list