This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to add __builtin_printf
- To: Zack Weinberg <zack at rabi dot columbia dot edu>
- Subject: Re: Patch to add __builtin_printf
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Wed, 20 Sep 2000 10:05:07 +0100 (BST)
- cc: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>, gcc-patches at gcc dot gnu dot org
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