This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch to suggest putc/fputs over printf("string") or printf("\n")
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 `------------------------