From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7B12E388A430; Sat, 6 Mar 2021 05:08:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B12E388A430 From: "cvs-commit at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: ice-on-valid-code, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Mar 2021 05:08:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99365 --- Comment #4 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:b49d23f3e238c08bdbc5b892b2ed0a57b5f5caf9 commit r11-7540-gb49d23f3e238c08bdbc5b892b2ed0a57b5f5caf9 Author: Patrick Palka 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 =3D=3D adc_uni= fy) when processing_template_decl !=3D 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) : Pass targs as outer_targs to do_auto_deduction. (placeholder_type_constraint_dependent_p): Define. (do_auto_deduction): When processing_template_decl !=3D 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.=