c++: Tuple of self-dependent classes [PR96926]
authorJason Merrill <jason@redhat.com>
Sat, 13 Feb 2021 05:40:11 +0000 (00:40 -0500)
committerJason Merrill <jason@redhat.com>
Fri, 19 Feb 2021 02:22:18 +0000 (21:22 -0500)
commit187d0d5871b1fa572b0238b4989fa067df56778f
tree4e944d1d7d0c29ce6c63f221e57c3336a4b996d0
parentbf81237eccb1d5d2d8078b1d2c5a0b9cc0258d61
c++: Tuple of self-dependent classes [PR96926]

When compiling this testcase, trying to resolve the initialization for the
tuple member ends up recursively considering the same set of tuple
constructor overloads, and since two of them separately depend on
is_constructible, the one we try second fails to instantiate
is_constructible because we're still in the middle of instantiating it the
first time.

Fixed by implementing an optimization that someone suggested we were already
doing: if we see a non-template candidate that is a perfect match for all
arguments, we can skip considering template candidates at all.  It would be
enough to do this only when LOOKUP_DEFAULTED, but it shouldn't hurt in other
cases.

gcc/cp/ChangeLog:

PR c++/96926
* call.c (perfect_conversion_p): New.
(perfect_candidate_p): New.
(add_candidates): Ignore templates after a perfect non-template.

gcc/testsuite/ChangeLog:

PR c++/96926
* g++.dg/cpp0x/overload4.C: New test.
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/overload4.C [new file with mode: 0644]