This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Optimize sprintf into strcpy if possible


 > This patch optimizes sprintf (x, "%s", y) into strcpy (x, y) and also
 > sprintf (x, "foowithoutpercentcharacter") into strcpy (x, "foo....").


One reason I didn't write this one when I initially did the stdio opts
was that I worried what happens when e.g. on older hosts sprintf is
declared in stdio.h to return char* ?

I think sunos4 is one such host, can you please test it there to make
sure it at least degrades gracefully (or perhaps make it actually
work?)

There might be some exception which allows decl conflicts for builtins
to work, I'm not sure about return types though.


Minor addition request:
You could probably add optimizing sprintf(x, "%c", c) into *x=(char)c;
using INDIRECT_REF, MODIFY_EXPR and CONVERT_EXPR to create the proper
tree expression.

		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]