This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize sprintf into strcpy if possible (take 2)
- To: Jakub Jelinek <jakub at redhat dot com>
- Subject: Re: [PATCH] Optimize sprintf into strcpy if possible (take 2)
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Wed, 11 Apr 2001 06:42:15 +0100 (BST)
- cc: <gcc-patches at gcc dot gnu dot org>
On Tue, 10 Apr 2001, Jakub Jelinek wrote:
> * gcc.dg/format/c90-printf-1.c: Add tests for string plus constant
> formats.
> --- gcc/testsuite/gcc.dg/format/c90-printf-1.c.jj Sun Jan 7 11:44:59 2001
> +++ gcc/testsuite/gcc.dg/format/c90-printf-1.c Tue Apr 10 17:50:12 2001
> @@ -29,6 +29,8 @@ foo (int i, int i1, int i2, unsigned int
> printf ("%.*d\n", i2, i);
> printf ("%*.*ld\n", i1, i2, l);
> printf ("%d %lu\n", i, ul);
> + printf ("%%d\n" + 1, i);
> + printf (5 + "%.-*d%3d\n", i);
These testcases would work better - i.e., fail with an unmodified compiler
but pass with a modified one - if in a separate file (e.g.
gcc.dg/format/plus-1.c) compiled with -Wformat=2. Such a file should also
have the unit tests for integer side non-constant or negative or too large
giving the non-literal warning.
--
Joseph S. Myers
jsm28@cam.ac.uk