Skip to content
Snippets Groups Projects
Commit 87ffd205 authored by Nathaniel Shead's avatar Nathaniel Shead
Browse files

c++/modules: Don't emit imported deduction guides [PR117397]


The ICE in the linked PR is caused because name lookup finds duplicate
copies of the deduction guides, causing a checking assert to fail.

This is ultimately because we're exporting an imported guide; when name
lookup processes 'dguide-5_b.H' it goes via the 'tt_entity' path and
just returns the entity from 'dguide-5_a.H'.  Because this doesn't ever
go through 'key_mergeable' we never set 'BINDING_VECTOR_GLOBAL_DUPS_P'
and so deduping is not engaged, allowing duplicate results.

Currently I believe this to be a perculiarity of the ANY_REACHABLE
handling for deduction guides; in no other case that I can find do we
emit bindings purely to imported entities.  As such, this patch fixes
this problem from that end, by ensuring that we simply do not emit any
imported deduction guides.  This avoids the ICE because no duplicates
need deduping to start with, and should otherwise have no functional
change because lookup of deduction guides will look at all reachable
modules (exported or not) regardless.

Since we're now deliberately not emitting imported deduction guides we
can use LOOK_want::NORMAL instead of LOOK_want::ANY_REACHABLE, since the
extra work to find as-yet undiscovered deduction guides in transitive
importers is not necessary here.

	PR c++/117397

gcc/cp/ChangeLog:

	* module.cc (depset::hash::add_deduction_guides): Don't emit
	imported deduction guides.
	(depset::hash::finalize_dependencies): Add check for any
	bindings referring to imported entities.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/dguide-5_a.H: New test.
	* g++.dg/modules/dguide-5_b.H: New test.
	* g++.dg/modules/dguide-5_c.H: New test.
	* g++.dg/modules/dguide-6.h: New test.
	* g++.dg/modules/dguide-6_a.C: New test.
	* g++.dg/modules/dguide-6_b.C: New test.
	* g++.dg/modules/dguide-6_c.C: New test.

Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: default avatarJason Merrill <jason@redhat.com>
parent 744a59f3
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment