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

Chip Salzenberg
Mon Jan 11 15:31:00 GMT 1999

According to Ulrich Drepper:
> gettext ("string with format") -> "some string with %%"

Finally, a real example -- and a good one.  Thanks.  Thus, if the
optimization is made, it should exclude the return value of gettext().

>    cp = my_malloc (100);
>    sprintf (cp, "foo");
>    strcat (cp, "bar");
> The compiler itself can never rewrite this to
>    cp = my_malloc (100); 
>    memcpy (mempcpy (cp, "foo", 3), "bar", 4);
> since it cannot assume that there are no side-effects on buf.

Sure it can -- standard functions like sprintf and strcat have
known behavior that can be depended on during optimization.
Chip Salzenberg      - a.k.a. -      <>
      "When do you work?"   "Whenever I'm not busy."

More information about the Gcc-patches mailing list