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")


 > From: Raja R Harinath <harinath@cs.umn.edu>
 > 
 > Raja R Harinath <harinath@cs.umn.edu> writes:
 > > "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:
 > > > 	printf("string\n") -> puts("string")
 > > 
 > > 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); }

In the given example, the printf call site sees a pointer variable,
not a string constant, so the optimization isn't performed.  Its only
performed for cases like printf("foo\n") where the string constant is
explicit.

 > 
 > I mean
 > 
 >   const char *const p = "foo\n";
 > 
 > - Hari

Ditto.

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