[C++ PATCH] Fix PRs 33112 and 33185

Doug Gregor doug.gregor@gmail.com
Wed Sep 19 13:39:00 GMT 2007

This patch fixes PRs 33112 (a P3) and 33185 (a P1), both of which are
canonical-type failures due to the mis-handling of canonical types for
arrays. My previous patch, which I thought had fixed these problems,
was bogus:


The attached patch fixes the problem for real. The fundamental issue
is that cplus_array_compare, which is used to match elements in a hash
table of ARRAY_TYPE nodes, was comparing via type equality, not by
pointer equality. So, we were combining ARRAY_TYPE nodes in a way that
was bound to cause problems later on. Moreover, we weren't putting
things into said hash table immediately, and in some cases the hash
table could get reallocated after we did an insertion but before we
committed the inserted value. Between these two errors, we ended up
with the hard-to-reproduce problems reported in these two PRs, which
depend on various pointer values and when the hash tables were

Tested i686-pc-linux-gnu; no regressions. Okay for mainline?

  - Doug

2007-09-19  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/33112
	PR c++/33185	
	* tree.c (cplus_array_compare): Compare pointers, not types.
	(build_cplus_array_type_1): Store new array type into the hash
	table before building the canonical type; build the canonical type
	(cp_build_qualified_type_real): Put all of the array types with
	cv-qualified element types into the C++ array hash table, built as
	variants of the unqualified versions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: array-canon.patch
Type: text/x-patch
Size: 5562 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070919/082d12cf/attachment.bin>

More information about the Gcc-patches mailing list