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 -> fputs transformations


 > From: "Joseph S. Myers" <jsm28@cam.ac.uk>
 > 
 > Some warnings on the more general optimisations:
 > 
 > Concatenating format specifiers won't work if $ operand numbers are
 > used.  Setting pedantic prevents printf optimisations from looking at such
 > formats for now, but it's something to be aware of in case a future C
 > standard adds $ formats.
 > 
 > %n formats also prevent concatenation.
 > 
 > All the usual cross-compilation issues of getting the right output for the
 > target system apply.
 > 
 > Floating point conversions should follow the runtime rounding mode - at
 > least within #pragma STDC FENV_ACCESS ON.
 > 
 > NaNs and infinities should be passed to the library for it to format in
 > its implementation-defined style.  Likewise, %p should also be passed to
 > the library at runtime.
 > 
 > %lc and %ls formats depend on the runtime locale.

Okay let's say I want to start with low hanging fruit.  I.e. not
having to worry about any of the above things like cross-compile, or
locale or whatever when evaluating printf at compile time.  Which
specifiers (with constant arguments) *are* allowed without regard to
these things?

I assume "%c" and "%s" with constant args are always okay?
How about integer specifiers?  I.e. are "%d", "%lx", etc. affected by
locale or other runtime env issues?

Similar question applies to concatenation.  Which specifiers are
explicitly always allowed?

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