[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 5 21:33:55 GMT 2021


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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:ff22b4e8d0613170601d28eec9462ea31147c7c7

commit r10-9209-gff22b4e8d0613170601d28eec9462ea31147c7c7
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Jan 5 16:33:07 2021 -0500

    c++: ICE with deferred noexcept when deducing targs [PR82099]

    In this test we ICE in type_throw_all_p because it got a deferred
    noexcept which it shouldn't.  Here's the story:

    In noexcept61.C, we call bar, so we perform overload resolution.  When
    adding the (only) candidate, we need to deduce template arguments, so
    call fn_type_unification as usually.  That deduces U to

      void (*) (int &, int &)

    which is correct, but its noexcept-spec is deferred_noexcept.  Then
    we call add_function_candidate (bar), wherein we try to create an
    implicit conversion sequence for every argument.  Since baz<int> is
    of unknown type, we instantiate_type it; it is a TEMPLATE_ID_EXPR
    so that calls resolve_address_of_overloaded_function.  But we crash
    there, because target_type contains the deferred_noexcept.

    So we need to maybe_instantiate_noexcept before we can compare types.
    resolve_overloaded_unification seemed like the appropriate spot, now
    fn_type_unification produces the function type with its noexcept-spec
    instantiated.  This shouldn't go against CWG 1330 because here we
    really need to instantiate the noexcept-spec.

    This also fixes class-deduction76.C, a dg-ice test I recently added,
    therefore this fix also fixes c++/90799, yay.

    gcc/cp/ChangeLog:

            PR c++/82099
            * pt.c (resolve_overloaded_unification): Call
            maybe_instantiate_noexcept after instantiating the function
            decl.

    gcc/testsuite/ChangeLog:

            PR c++/82099
            * g++.dg/cpp0x/noexcept61.C: New test.


More information about the Gcc-bugs mailing list