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 to add __builtin_printf("string\n") -> puts("string")


"Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:
> This patch adds another __builtin_printf transformation, namely:
> 
> 	printf("string\n") -> puts("string")
> 
> Note this transformation is a subset of the printf->fputs one, however
> it is still is worthwhile to have it because it can be done even if
> the user didn't include stdio.h.  (Also there's no guarantee I'll be
> able to get printf->fputs working for c++ so this is a good fallback.)

Isn't this a size pessimization: you may need to store two copies of
the constant string -- one with the trailing '\n' and one without.
Especially in the case

   const char *p = "foo\n";
   void bar () { printf(p); }

- Hari
-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash

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