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")
According to Ulrich Drepper:
> 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.
Yes, it *is* possible. Standard functions have standard semantics.
Or did you mean your example to include intervening statements, which
you didn't actually write?
--
Chip Salzenberg - a.k.a. - <chip@perlsupport.com>
"When do you work?" "Whenever I'm not busy."