I found this bug while debugging a failure in pph images with template
classes. When writing the decl_specializations table, the writer
calls htab_elements() to output the length of the table. It then
traverses the table with htab_traverse_noresize() to emit all the
entries.
The reader uses that value to know how many entries it needs to read.
However, the table was out of sync wrt empty entries because
reregister_specialization does a lookup using INSERT instead of
NO_INSERT, so it was leaving a bunch of empty entries in it (thanks
Jakub for helping me diagnose this).
Since empty entries are never traversed by htab_traverse, they were
never written out and the reader was trying to read more entries than
there really were.
Jason, I don't think this is affecting any bugs in trunk, but it looks
worth fixing. OK for trunk?
Diego.
* pt.c (reregister_specialization): Call htab_find_slot with
NO_INSERT.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 04e7767..2366dc9 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1648,8 +1648,8 @@ reregister_specialization (tree spec, tree tinfo, tree
new_spec)
elt.args = TI_ARGS (tinfo);
elt.spec = NULL_TREE;
- slot = (spec_entry **) htab_find_slot (decl_specializations, &elt, INSERT);
- if (*slot)
+ slot = (spec_entry **) htab_find_slot (decl_specializations, &elt,
NO_INSERT);
+ if (slot && *slot)
{
gcc_assert ((*slot)->spec == spec || (*slot)->spec == new_spec);
gcc_assert (new_spec != NULL_TREE);
--
This patch is available for review at http://codereview.appspot.com/5190046