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


On Wed, 20 Sep 2000, Zack Weinberg wrote:

> static const char nothing_happens[] = "Nothing happens.\n"
> 
> ...
> 
> printf(nothing_happens);
> 
> Be nice if we went and fished the text out of the VAR_DECL when we could,
> and checked arguments as normal.  [A bare "extern const char *nothing_happens"
> should still get warned about - you don't know where the initializer will
> come from, it could be unchecked user input.]

I'll add this to the TODO list in the next update (once the intmax_t patch
is dealt with).  But in the particular case given with no arguments for
the format, if anyone complains about the new warning at -Wall then we can
recommend use of fputs() or printf("%s", ...) instead of printf(); -Wall
already makes what are essentially stylistic warnings for some cases (e.g.
-Wparentheses) where the code may well be correct but is considered dodgy.

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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