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]
Other format: [Raw text]

Re: [PATCH] Fix PR middle-end/37669


On Mon, Oct 20, 2008 at 01:58:12PM -0700, Adam Nemet wrote:
> Jakub Jelinek writes:
> > See my comment in bugzilla, I think this is an overkill, we should just
> > remove the loop which might have been useful when we had to iterate through
> > the arguments, but isn't any longer.  The only values of arg_mask are
> > 1, 2 and 4 and val array has 3 elements anyway, so if you want to keep the
> > loop, you could at least use i < nargs && i < 3, which is cheaper than
> > floor_log2.
> 
> Here is an untested version of the patch without the loop.  I can give it a
> round of testing if you like this better.

Yes, that looks better, though I'd call the var arg_idx, not len_arg, as it
is len only for certain type values, it is a string for others.

Also, you should include a testcase with the patch, e.g.
following testcase reproduces it well for me:

--- gcc/testsuite/gcc.c-torture/compile/pr37669.c	2008-09-30 10:18:57.740011359 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr37669.c	2008-10-20 23:44:27.000000000 +0200
@@ -0,0 +1,14 @@
+/* PR middle-end/37669 */
+
+#define FMT10 "%d%d%d%d%d%d%d%d%d%d"
+#define FMT100 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10
+#define FMT1000 FMT100 FMT100 FMT100 FMT100 FMT100 \
+		FMT100 FMT100 FMT100 FMT100 FMT100
+#define ARG10 , i, i, i, i, i, i, i, i, i, i
+#define ARG100 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10
+#define ARG1000 ARG100 ARG100 ARG100 ARG100 ARG100 \
+		ARG100 ARG100 ARG100 ARG100 ARG100
+void foo (char *s, int i, int j)
+{
+  __builtin___snprintf_chk (s, i, 1, j, FMT1000 ARG1000);
+}

	Jakub


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