]> git.ipfire.org Git - people/ms/gcc.git/commit
c++: fix ICE in joust_maybe_elide_copy [PR106675]
authorMarek Polacek <polacek@redhat.com>
Fri, 10 Feb 2023 22:26:57 +0000 (17:26 -0500)
committerMarek Polacek <polacek@redhat.com>
Wed, 15 Feb 2023 00:09:14 +0000 (19:09 -0500)
commit53512f0055186d5556e9859c1f8beb25d2d28530
treeaa0b5bf8b252a5bd0945d93abc4b7b7da57f0e3e
parent2e558da77adade314d4373397c93a700717d50cd
c++: fix ICE in joust_maybe_elide_copy [PR106675]

joust_maybe_elide_copy checks that the last conversion in the ICS for
the first argument is ck_ref_bind, which is reasonable, because we've
checked that we're dealing with a copy/move constructor.  But it can
also happen that we couldn't figure out which conversion function is
better to convert the argument, as in this testcase: joust couldn't
decide if we should go with

  operator foo &()

or

  operator foo const &()

so we get a ck_ambig, which then upsets joust_maybe_elide_copy.  Since
a ck_ambig can validly occur, I think we should just return early, as
in the patch below.

PR c++/106675

gcc/cp/ChangeLog:

* call.c (joust_maybe_elide_copy): Return false for ck_ambig.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/overload-conv-5.C: New test.

(cherry picked from commit cce62625025380c2ea2a220deb10f8f355f83abf)
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/overload-conv-5.C [new file with mode: 0644]