patch to suggest putc/fputs over printf("string") or printf("\n")
Jeffrey A Law
Sun Jan 10 18:27:00 GMT 1999
In message < 199901102156.NAA09434@atrus.synopsys.com >you write:
> > > But there are also situations where the replacement returned by a
> > > gettext call with an argument without format specifiers contains
> > > format specifiers. A call could look like this:
> > >
> > > printf (gettext ("no format here"), some_variable)
> > >
> > > The return value of the gettext call could be "value %d".
> > And in that case we can not and must not optimize.
> I think that this is bad practice. The gettext argument should have a
> %d and all translations should have a %d. Otherwise we can't detect
> format errors with gettext.
I'm not familiar enough with the issues behind gettext to know why they do
this. But it's simply wrong for the compiler to do any tranformations if the
format string is not a compile time constant.
One might argue that having the integer argument "some_variable" is enough for
gcc to determine what format specifiers are in the string. That may be the
case; we'd need a language lawyer to sort it out though. In the absense of
concrete information I'd just do nothing for such cases. If we later find that
they can be optimzied, we can always refine the optimization.
More information about the Gcc-patches