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

Ulrich Drepper drepper@cygnus.com
Mon Jan 11 15:53:00 GMT 1999


Chip Salzenberg <chip@perlsupport.com> writes:

> > 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.

No, it's not possible.  The compiler cannot assume that the buffer is
not used somewhere else.  In a signal handler or in another thread.
I've explicitly used `my_malloc' to point this out.

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



More information about the Gcc-patches mailing list