public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99365] [11 Regression] ICE on partial specialization with constrained placeholder NTTP
Date: Sat, 06 Mar 2021 05:08:09 +0000	[thread overview]
Message-ID: <bug-99365-4-9ZjmSbdo5H@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99365-4@http.gcc.gnu.org/bugzilla/>

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

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

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

commit r11-7540-gb49d23f3e238c08bdbc5b892b2ed0a57b5f5caf9
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sat Mar 6 00:07:35 2021 -0500

    c++: adc_unify deduction with constrained auto [PR99365]

    My recent r11-7454 changed the way do_auto_deduction handles constrained
    placeholders during template argument deduction (context == adc_unify)
    when processing_template_decl != 0.  Before the patch, we would just
    ignore the constraints on the placeholder, and return the deduced type.
    After the patch, we now punt and return the original placeholder type

    While this change fixed instances where we'd prematurely resolve a
    constrained placeholder return or variable type with non-dependent
    initializer at template parse time (such as PR96444), it broke the
    adc_unify callers that rely on the previous behavior.

    This patch restores the previous behavior during adc_unify deduction
    while retaining the new behavior only during adc_variable_type or
    adc_return_type deduction.

    We additionally now need to pass the outer template arguments to
    do_auto_deduction during unify, for sake of constraint checking.
    But we want to avoid substituting these outer arguments into type
    when the caller has already done so, so this patch adds a
    TEMPLATE_TYPE_LEVEL check to do_auto_deduction to that effect.

    This above is enough to fix partial specialization of non-nested
    templates with constrained 'auto' template parameters, but it doesn't
    fix the nested template case, ultimately because
    most_specialized_partial_spec passes only the innermost template
    arguments to get_partial_spec_bindings, and so outer_targs during
    do_auto_deduction (called from unify) contains only the innermost
    template arguments, and this breaks satisfaction.  Fixing this properly
    is perhaps too risky at this stage, so this patch adds a hack to
    do_auto_deduction to compensate for callers that don't supply all outer
    template arguments.  The goal of this hack is to ensure placeholder type
    constraint checking continues to work whenever it worked before
    r11-7454, namely whenever the constraint is non-dependent.

    Finally, this patch allows do_auto_deduction to resolve a constrained
    placeholder type ahead of time (at template parse time), as long as the
    constraint is non-dependent.

    gcc/cp/ChangeLog:

            PR c++/99365
            * pt.c (unify) <case TEMPLATE_TYPE_PARM>: Pass targs as
            outer_targs to do_auto_deduction.
            (placeholder_type_constraint_dependent_p): Define.
            (do_auto_deduction): When processing_template_decl != 0
            and context is adc_unify and we have constraints, pretend the
            constraints are satisfied instead of punting.  Otherwise don't
            punt unless placeholder_type_constraint_dependent_p holds.
            Add some clarifying sanity checks.  Add a hack to add missing
            outermost template levels to outer_args before checking
            satisfaction.  Don't substitute outer_targs into type if it's
            already been done.

    gcc/testsuite/ChangeLog:

            PR c++/99365
            * g++.dg/cpp2a/concepts-partial-spec9.C: New test.
            * g++.dg/cpp2a/concepts-placeholder4.C: New test.

  parent reply	other threads:[~2021-03-06  5:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 17:48 [Bug c++/99365] New: " johelegp at gmail dot com
2021-03-03 19:53 ` [Bug c++/99365] [11 Regression] " mpolacek at gcc dot gnu.org
2021-03-03 21:17 ` ppalka at gcc dot gnu.org
2021-03-03 22:54 ` ppalka at gcc dot gnu.org
2021-03-03 22:55 ` ppalka at gcc dot gnu.org
2021-03-06  5:08 ` cvs-commit at gcc dot gnu.org [this message]
2021-03-06 15:35 ` ppalka at gcc dot gnu.org
2021-03-07 17:47 ` johelegp at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99365-4-9ZjmSbdo5H@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).