When compiling a function with parameter of a pointer to a vector constant type, the compiler calls a recursive function and is not able to get out. Concretely, in gcc/cp/mangle.c file, in function write_type: if (write_CV_qualifiers_for_type (type) > 0) /* If TYPE was CV-qualified, we just wrote the qualifiers; now mangle the unqualified type. The recursive call is needed here since both the qualified and unqualified types are substitution candidates. */ write_type (TYPE_MAIN_VARIANT (type)); But TYPE_MAIN_VARIANT (type) has been set as type itself in gcc/tree.c function make_node_stat: case tcc_type: ... TYPE_MAIN_VARIANT (t) = t; Therefor the write_type function runs into a dead recursion. The bug was detected on spu, and the same error appears on PowerPC and Intel too. The following is a test case on Intel: void bar( int __attribute__((vector_size(16))) * a, int __attribute__((vector_size(16))) * const b); int instance(void) { int __attribute__((vector_size(16))) a[1], b[1]; bar(a, b); }
A regression hunt of mainline on powerpc-linux identified the following patch, where the compiler went from compiling in a reasonable time to taking more than three seconds for the submitter's testcase: r117696 | bonzini | 2006-10-13 15:59:03 +0000 (Fri, 13 Oct 2006) http://gcc.gnu.org/viewcvs?view=rev&rev=117696
Is this really a regression from 4.1.1? I got the same error on 4.1.1, before the patch r117696 was applied.
It compiles quickly for me with GCC 4.1.1 for powerpc64-linux and with a 4.1.1 cross compiler for i686-linux. Is your 4.1.1 compiler from FSF sources, or might it have additional backports?
Okey, I have a Red Hat GCC 4.1.1, which might be different from the FSF one.
This patch can fix the problem: Index: gcc/tree.c =================================================================== --- gcc.orig/tree.c +++ gcc/tree.c @@ -7609,8 +7609,11 @@ reconstruct_complex_type (tree type, tre else return bottom; - TYPE_READONLY (outer) = TYPE_READONLY (type); - TYPE_VOLATILE (outer) = TYPE_VOLATILE (type); + if (TYPE_READONLY (type)) + build_qualified_type(outer, TYPE_QUAL_CONST); + + if (TYPE_VOLATILE (type)) + build_qualified_type(outer, TYPE_QUAL_VOLATILE); return outer; }
Changing component to middle-end as the problem is not actually in the C++ front-end.
Sa's patch isn't quite correct as it ignores the result of the build_qualified_type call. The following patch should fix that: diff -urNp toolchain/gcc.orig/gcc/tree.c toolchain/gcc/gcc/tree.c --- toolchain/gcc.orig/gcc/tree.c 2007-08-12 15:57:05.442520932 +0200 +++ toolchain/gcc/gcc/tree.c 2007-08-12 16:07:42.516093968 +0200 @@ -6554,10 +6554,7 @@ reconstruct_complex_type (tree type, tre else return bottom; - TYPE_READONLY (outer) = TYPE_READONLY (type); - TYPE_VOLATILE (outer) = TYPE_VOLATILE (type); - - return outer; + return build_qualified_type (outer, TYPE_QUALS (type)); } /* Returns a vector tree node given a mode (integer, vector, or BLKmode) and
Subject: Bug 32970 Author: bje Date: Fri Aug 17 05:24:24 2007 New Revision: 127578 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127578 Log: PR middle-end/32970 gcc/ * tree.c (reconstruct_complex_type): For a pointer to a vector, use build_qualified_type to retain qualifiers of the base type. testsuite/ * g++.dg/ext/altivec-14.C: New test. Added: trunk/gcc/testsuite/g++.dg/ext/altivec-14.C Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree.c
Fixed in r127578.