]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: address deduction and concepts [CWG2918]
authorJason Merrill <jason@redhat.com>
Fri, 11 Oct 2024 18:52:43 +0000 (14:52 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 14 Oct 2024 19:29:26 +0000 (15:29 -0400)
commitcacbb4daac3e9a9d86992fef1a7c607b4cee5f22
tree94bb6b2c34bdf6f8102acf2519a1d8e8d031a8da
parentde0320712d026a2d1eeb57aef277fa5a91808ac2
c++: address deduction and concepts [CWG2918]

CWG2918 changes deduction from an overload set for the case where multiple
candidates succeed and have the same type; previously this made the overload
set a non-deduced context, now it succeeds since the result is consistent
between the candidates.

This is needed for cases of overloading based on requirements, where we want
to choose the most constrained overload.  I also needed to adjust
resolve_address_of_overloaded_function accordingly; we already handled the
comparison for template candidates in most_specialized_instantiation, but
need to also do the comparison for non-template candidates such as member
functions of a class template.

CWG 2918 (proposed)

gcc/cp/ChangeLog:

* cp-tree.h (most_constrained_function): Declare..
* class.cc (resolve_address_of_overloaded_function): Call it.
* pt.cc (get_template_for_ordering): Handle list from
resolve_address_of_overloaded_function.
(most_constrained_function): No longer static.
(resolve_overloaded_unification): Always compare type rather
than decl.

gcc/testsuite/ChangeLog:

* g++.dg/DRs/dr2918.C: New test.
gcc/cp/class.cc
gcc/cp/cp-tree.h
gcc/cp/pt.cc
gcc/testsuite/g++.dg/DRs/dr2918.C [new file with mode: 0644]