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

Jeffrey A Law
Mon Jan 11 11:56:00 GMT 1999

  In message < >you write:
  > (Jeffrey A Law) writes:
  > > So, I still don't see why you object  to the optimization.
  > Because may introduce problems.  The compiler will never be able to
  > determine with 100% accuracy whether the transformation is correct.
  > If the uses is pointed to the case, instead, s/he can decide.
Err, when the format string is a compile time constant, the compiler can
determine it is safe to make such transformations.

Simlarly if via attributes we can determine the string has no formatting
chars, then we can make the transformation.

If this is not the case, please show a specific example.

  > Letting the compiler do a suboptimal job will make developers even
  > lazier.  With a warning about the code the developer has the chance to
  > think about the code and maybe rewrite it in a better way.  In the
  > above example the sprintf call might be hidden in a macro call so it
  > is non-obvious at a first few.  The compiler could silently generate a
  > bit better code but only a warning will help to develop optimal code
  > since the rest cannot be done by the compiler alone.
Not getting an optimal solution from the start does not prevent us from working
on these kinds of optimizations.   Sorry if you feel differently.

Improve and iterate.


More information about the Gcc-patches mailing list