http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48029
--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-09 21:43:02 UTC --- OK, the problem here is as follows: when we first declare the myvectypes and mytype3, vector<string> has not been instantiated, so we mark the array, and the pointer to the array, for structural equality comparison. When we actually go to instantiate mytype3, we complete vector<string> and rebuild the array and pointer types, and use those to look up the template specialization. Which fails to find the one we already had because the new pointer type has TYPE_CANONICAL and therefore hashes differently from the one that didn't. We deal with ARRAY_TYPE specially in iterative_hash_template_arg, but it seems now that we need to apply the same special treatment to any compound type which involves an array. Or we could stop creating equivalent ARRAY_TYPEs, some which have TYPE_CANONICAL, and some which don't.