From: Jason Merrill Date: Fri, 7 Dec 2012 04:58:45 +0000 (-0500) Subject: re PR c++/55032 (Internal compiler error: in strip_typedefs, at cp/tree.c:1199) X-Git-Tag: releases/gcc-4.6.4~247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ebf1f40781875ddd9e01688f912919f624bbdc8;p=thirdparty%2Fgcc.git re PR c++/55032 (Internal compiler error: in strip_typedefs, at cp/tree.c:1199) PR c++/55032 * tree.c (build_array_type_1): Re-layout if we found it in the hash table. From-SVN: r194286 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 45e613e8ef85..80e72a939884 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-12-06 Jason Merrill + + PR c++/55032 + * tree.c (build_array_type_1): Re-layout if we found it in the + hash table. + 2012-12-05 John David Anglin Backport for mainline: diff --git a/gcc/testsuite/g++.dg/template/array24.C b/gcc/testsuite/g++.dg/template/array24.C new file mode 100644 index 000000000000..07879d250c05 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array24.C @@ -0,0 +1,22 @@ +// PR c++/55032 + +template +struct vec3t { + T c[3]; +}; + +typedef vec3t vec3; + +class Bounds { + public: + Bounds(const vec3 bb[2]); + void foo(const vec3 & v) { v.c[0]; } +}; + +template +void work(T& value); + +void foo() { + vec3 bb[2]; + work(bb); +} diff --git a/gcc/tree.c b/gcc/tree.c index 83a07117fe8e..7a0ac82a3d10 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7282,10 +7282,15 @@ build_array_type_1 (tree elt_type, tree index_type, bool shared) if (shared) { + tree old_t = t; hashval_t hashcode = iterative_hash_object (TYPE_HASH (elt_type), 0); if (index_type) hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode); t = type_hash_canon (hashcode, t); + if (t != old_t) + /* Lay it out again in case the element type has been completed since + the array was added to the hash table. */ + layout_type (t); } if (TYPE_CANONICAL (t) == t)