https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104622

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:03c83cf7aa1110e427beb00ea95767dfaf50d694

commit r12-7632-g03c83cf7aa1110e427beb00ea95767dfaf50d694
Author: Patrick Palka <ppa...@redhat.com>
Date:   Sat Mar 12 15:00:49 2022 -0500

    c++: ICE with bad conversion shortcutting [PR104622]

    When shortcutting bad argument conversions during overload resolution,
    we assume conversions get computed in sequential order and that therefore
    the conversion array is incomplete iff the last conversion is missing.
    But this assumption turns out to be wrong for templates, because during
    deduction check_non_deducible_conversion can compute an argument
    conversion out of order.

    So in the testcase below, at the end of add_template_candidate the
    conversion array looks like {bad_conv, NULL, good_conv} where the last
    conversion was computed during deduction and the first one later from
    add_function_candidate.  We need to add this candidate to bad_fns since
    not all of its argument conversions were computed, but we don't do so
    because the last conversion isn't missing.

    This patch fixes this by checking for a missing conversion exhaustively
    instead.  In passing, this cleans up check_non_deducible_conversion given
    that the only values of 'strict' we expect to see here the enumerators
    of unification_kind_t.

            PR c++/104622

    gcc/cp/ChangeLog:

            * call.cc (missing_conversion_p): Define.
            (add_candidates): Use it.
            * pt.cc (check_non_deducible_conversion): Change type of strict
            parameter to unification_kind_t and directly test for DEDUCE_CALL.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/conv18.C: New test.

Reply via email to