https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99170
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathan Sidwell <nat...@gcc.gnu.org>: https://gcc.gnu.org/g:499193a692efa33c9b2fe3ad8da0f4d5e5fd0e0c commit r11-7493-g499193a692efa33c9b2fe3ad8da0f4d5e5fd0e0c Author: Nathan Sidwell <nat...@acm.org> Date: Wed Mar 3 11:22:56 2021 -0800 c++: Defer specialization registration [PR 99170] This defers inserting specializations into the specialization table, until we have completed their streaming. When streaming a cluster we ensure that all imports are populated before any of the cluster, so they need no visibility of other specializations. Further within the same import, we've already partitioned the graph, so no earlier cluster can be refering to a specialization in a later cluster. Inserting them early causes problems when other specializations of the same template are inserted. (This doesn't fix 99170, but is a necessary change for that PR). Earlier on, I had less deferred processing, but it has become clearer that deferred worklists are the right way of handling a few things. This patch highlights a fixme, in that we're streaming a key twice, and need not do that, but I wanted to get correctness first. Besides the second streaming will end up being a back reference, which is of course much cheaper than a by-value stream. PR c++/99170 gcc/cp/ * module.cc (trees_out::decl_value): Stream specialization keys after decl. (trees_in::decl_value): Stream them back and insert after completing the decl. (trees_out::key_mergeable): Drop some streaming here ... (trees_in::key_mergeable): ... and here. Don't insert into specialization tables.