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]

[PATCH] Fix ICE in build_function_type_skip_args (PR tree-optimization/40792)


Hi!

On the following testcase build_function_type_skip_args is called with
bitmask { 0, 1 } on a function with argument 0, 1 and ... after it.
In this case new_reversed is obviously NULL (the two arguments are removed
and ... is represented by NULL TREE_CHAIN rather than void_list_node).
build_function_type_skip_args asserts that this is not the case, but I fail
to see why, there is nothing wrong on NULL TYPE_ARG_TYPES, e.g. C++ FE
happily creates it for void foo (...) { }.  The problematic case could be if
va_start with an argument that is going to be removed, but that would be
already problematic even if removing just that last argument before ... and
not other arguments.  Except that those functions never hit here as they
aren't considered inlinable, thus not suitable for versioning.

Ok for trunk/4.4 if bootstrap/regtest passes (given that it just removes an
assert that isn't triggered during bootstrap nor regtest and that this
testcase on which it triggered compiles just fine that is quite pointless
exercise, but I'll do it anyway)?

2009-07-20  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/40792
	* tree.c (build_function_type_skip_args): Remove bogus assert.

	* gcc.dg/pr40792.c: New test.

--- gcc/tree.c.jj	2009-07-07 14:24:59.000000000 +0200
+++ gcc/tree.c	2009-07-20 11:32:30.000000000 +0200
@@ -5960,7 +5960,6 @@ build_function_type_skip_args (tree orig
       else
 	new_reversed = void_list_node;
     }
-    gcc_assert (new_reversed);
 
   /* Use copy_node to preserve as much as possible from original type
      (debug info, attribute lists etc.)
--- gcc/testsuite/gcc.dg/pr40792.c.jj	2009-07-20 11:33:05.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr40792.c	2009-07-20 11:33:32.000000000 +0200
@@ -0,0 +1,21 @@
+/* PR tree-optimization/40792 */
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+void foo (int, char *, int *);
+
+void
+bar (int *a, int *b, ...)
+{
+  int c;
+  char d[256];
+  foo (*b, d, &c);
+}
+
+static int a, b;
+
+void
+baz (int c)
+{
+  bar (&a, &b);
+}

	Jakub


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