This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: patch to suggest putc/fputs over printf("string") or printf("\n")


Jeffrey A Law <law@hurl.cygnus.com> writes:

> OK.  Then the attributes are just hints.  From an optimization
> standpoint we must ignore them.  Which falls back to what I said in
> my original message, if the format string is not a compile-time
> constant, then we can not optimize.  Period.  Either we have
> accurate attributes, or we do not.  If the attributes are not
> accurate, then we can not use them for optimization purposes.

It cannot be optimized automatically but the compiler still knows
enough to warn the user.

You should really look around, not only only in the gcc sources.
Almost all newly written code and almost all GNU packages beside gcc
use gettext.  I.e., the case where printf is called without gettext is
getting less important with every day.  It's not just a point I made
up to throw you stones in your way, this is reality.

> We're not talking about warnings.  We're talking about
> optimizations.  We could still add the warnings if we think they are
> useful.

*You* are not talking about warnings, I did all the time.  My whole
point is to emit warnings about these missed optimizations.

> My goal is to be able to rewrite single statements which call the printf
> family of functions and where the format string is a compile time constant.
> I'm not particularly concerned about multi-statement calls.

This is so short-sighted.  You'll make it harder for programmers to
write really good code for the benefit of a few initial optimizations.

> I don't think -W options should impact code generation.  Ever.  Certainly we
> would have a flag for the optimization, which the user could turn off.

If this is the policy, fine.  But then make it possible to emit
warnings in case the optimizations are not chosen to be performed
automatically.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]