From dbf27f01fa7e35c9c9e12ecbccbf306f2b82c681 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 6 Dec 2012 20:20:34 +0000 Subject: [PATCH] PR c++/55032 * tree.c (build_array_type_1): Re-layout if we found it in the hash table. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194265 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/template/array24.C | 22 ++++++++++++++++++++++ gcc/tree.c | 5 +++++ 3 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/array24.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7da4e1f..cecd1ef 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-06 Jack Howarth PR 55599/sanitizer diff --git a/gcc/testsuite/g++.dg/template/array24.C b/gcc/testsuite/g++.dg/template/array24.C new file mode 100644 index 0000000..07879d2 --- /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 7cacb2a..429db49 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7505,7 +7505,12 @@ build_array_type_1 (tree elt_type, tree index_type, bool shared) hashval_t hashcode = iterative_hash_object (TYPE_HASH (elt_type), 0); if (index_type) hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode); + tree old_t = t; 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) -- 2.7.4