public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/102412] New: Template argument deduction fails when using concept as defaulted non-type template parameter @ 2021-09-20 16:45 joeloser93 at gmail dot com 2021-09-20 18:36 ` [Bug c++/102412] " ppalka at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: joeloser93 at gmail dot com @ 2021-09-20 16:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102412 Bug ID: 102412 Summary: Template argument deduction fails when using concept as defaulted non-type template parameter Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: joeloser93 at gmail dot com Target Milestone: --- When using a defaulted non-type template parameter whose value is from a concept, GCC is unable to deduce the template correctly when calling the function template. Clang accepts this code and it should be valid. ``` #include <concepts> template<class T, class U> concept different_from = not std::is_same_v<T, U>; template<class T, auto B = different_from<T, int>> void f() {} template<class T, auto B = not std::is_same_v<T, int>> void g() {} int main() { f<double>(); // fails to compile g<double>(); // compiles } ``` See it live at https://godbolt.org/z/n1zrzGPoq ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102412] Template argument deduction fails when using concept as defaulted non-type template parameter 2021-09-20 16:45 [Bug c++/102412] New: Template argument deduction fails when using concept as defaulted non-type template parameter joeloser93 at gmail dot com @ 2021-09-20 18:36 ` ppalka at gcc dot gnu.org 2021-09-22 15:18 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: ppalka at gcc dot gnu.org @ 2021-09-20 18:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102412 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org Target Milestone|--- |11.3 Last reconfirmed| |2021-09-20 Ever confirmed|0 |1 --- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> --- Confirmed. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102412] Template argument deduction fails when using concept as defaulted non-type template parameter 2021-09-20 16:45 [Bug c++/102412] New: Template argument deduction fails when using concept as defaulted non-type template parameter joeloser93 at gmail dot com 2021-09-20 18:36 ` [Bug c++/102412] " ppalka at gcc dot gnu.org @ 2021-09-22 15:18 ` cvs-commit at gcc dot gnu.org 2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org 2021-10-06 14:19 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-09-22 15:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102412 --- Comment #2 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:9329344a6d81a6a5e3bd171167ebc7b158bb44f4 commit r12-3822-g9329344a6d81a6a5e3bd171167ebc7b158bb44f4 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Sep 22 11:16:53 2021 -0400 c++: concept-ids and value-dependence [PR102412] The problem here is that uses_template_parms returns true for all concept-ids (even those with non-dependent arguments), so when a concept-id is used as a default template argument then during deduction the default argument is considered dependent even after substituting into it, which leads to deduction failure (from type_unification_real). This patch fixes this by implementing the resolution of CWG 2446 which says a concept-id is dependent only if its arguments are. DR 2446 PR c++/102412 gcc/cp/ChangeLog: * constexpr.c (cxx_eval_constant_expression) <case TEMPLATE_ID_EXPR>: Check value_dependent_expression_p instead of processing_template_decl. * pt.c (value_dependent_expression_p) <case TEMPLATE_ID_EXPR>: Return true only if any_dependent_template_arguments_p. (instantiation_dependent_r) <case CALL_EXPR>: Remove this case. <case TEMPLATE_ID_EXPR>: Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-nondep2.C: New test. * g++.dg/cpp2a/concepts-nondep3.C: New test. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102412] Template argument deduction fails when using concept as defaulted non-type template parameter 2021-09-20 16:45 [Bug c++/102412] New: Template argument deduction fails when using concept as defaulted non-type template parameter joeloser93 at gmail dot com 2021-09-20 18:36 ` [Bug c++/102412] " ppalka at gcc dot gnu.org 2021-09-22 15:18 ` cvs-commit at gcc dot gnu.org @ 2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org 2021-10-06 14:19 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-10-06 14:15 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102412 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:5a411459b73b65d8a1235a16d6e2aac4eed17338 commit r11-9082-g5a411459b73b65d8a1235a16d6e2aac4eed17338 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Sep 22 11:16:53 2021 -0400 c++: concept-ids and value-dependence [PR102412] The problem here is that uses_template_parms returns true for all concept-ids (even those with non-dependent arguments), so when a concept-id is used as a default template argument then during deduction the default argument is considered dependent even after substituting into it, which leads to deduction failure (from type_unification_real). This patch fixes this by implementing the resolution of CWG 2446 which says a concept-id is dependent only if its arguments are. DR 2446 PR c++/102412 gcc/cp/ChangeLog: * constexpr.c (cxx_eval_constant_expression) <case TEMPLATE_ID_EXPR>: Check value_dependent_expression_p instead of processing_template_decl. * pt.c (value_dependent_expression_p) <case TEMPLATE_ID_EXPR>: Return true only if any_dependent_template_arguments_p. (instantiation_dependent_r) <case CALL_EXPR>: Remove this case. <case TEMPLATE_ID_EXPR>: Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-nondep2.C: New test. * g++.dg/cpp2a/concepts-nondep3.C: New test. (cherry picked from commit 9329344a6d81a6a5e3bd171167ebc7b158bb44f4) ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102412] Template argument deduction fails when using concept as defaulted non-type template parameter 2021-09-20 16:45 [Bug c++/102412] New: Template argument deduction fails when using concept as defaulted non-type template parameter joeloser93 at gmail dot com ` (2 preceding siblings ...) 2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org @ 2021-10-06 14:19 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: ppalka at gcc dot gnu.org @ 2021-10-06 14:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102412 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> --- Fixed for GCC 11.3 and 12. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-06 14:19 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-09-20 16:45 [Bug c++/102412] New: Template argument deduction fails when using concept as defaulted non-type template parameter joeloser93 at gmail dot com 2021-09-20 18:36 ` [Bug c++/102412] " ppalka at gcc dot gnu.org 2021-09-22 15:18 ` cvs-commit at gcc dot gnu.org 2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org 2021-10-06 14:19 ` ppalka at gcc dot gnu.org
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).