public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100374] New: Type-constraints of member function templates should not be substituted into during implicit instantiation
@ 2021-05-01 13:48 rs2740 at gmail dot com
  2021-05-03 15:20 ` [Bug c++/100374] " ppalka at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rs2740 at gmail dot com @ 2021-05-01 13:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100374
           Summary: Type-constraints of member function templates should
                    not be substituted into during implicit instantiation
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

template<class T, class U>
concept C = true;

template <class T>
struct Foo
{
  template <C<typename T::value_type> U>
  void bar()
  {
  }
};

Foo<float> f;

GCC trunk with -std=c++20 produces:

<source>: In instantiation of 'struct Foo<float>':
<source>:13:12:   required from here
<source>:8:8: error: 'float' is not a class, struct, or union type
    8 |   void bar()
      |        ^~~

[temp.inst]/17 says that type-constraints like C<typename T::value_type> should
not be substituted into during the implicit instantiation of the declaration of
Foo<float>::bar:

The type-constraints and requires-clause of a template specialization or member
function are not instantiated along with the specialization or function itself,
even for a member function of a local class; substitution into the atomic
constraints formed from them is instead performed as specified in
[temp.constr.decl] and [temp.constr.atomic] when determining whether the
constraints are satisfied or as specified in [temp.constr.decl] when comparing
declarations.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100374] Type-constraints of member function templates should not be substituted into during implicit instantiation
  2021-05-01 13:48 [Bug c++/100374] New: Type-constraints of member function templates should not be substituted into during implicit instantiation rs2740 at gmail dot com
@ 2021-05-03 15:20 ` ppalka at gcc dot gnu.org
  2022-05-27 18:40 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-03 15:20 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-05-03

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100374] Type-constraints of member function templates should not be substituted into during implicit instantiation
  2021-05-01 13:48 [Bug c++/100374] New: Type-constraints of member function templates should not be substituted into during implicit instantiation rs2740 at gmail dot com
  2021-05-03 15:20 ` [Bug c++/100374] " ppalka at gcc dot gnu.org
@ 2022-05-27 18:40 ` ppalka at gcc dot gnu.org
  2022-06-03 13:29 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-27 18:40 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100374] Type-constraints of member function templates should not be substituted into during implicit instantiation
  2021-05-01 13:48 [Bug c++/100374] New: Type-constraints of member function templates should not be substituted into during implicit instantiation rs2740 at gmail dot com
  2021-05-03 15:20 ` [Bug c++/100374] " ppalka at gcc dot gnu.org
  2022-05-27 18:40 ` ppalka at gcc dot gnu.org
@ 2022-06-03 13:29 ` cvs-commit at gcc dot gnu.org
  2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
  2022-07-21 16:49 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-03 13:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:43c013df02fdb07f9b7a5e7e6669e6d69769d451

commit r13-981-g43c013df02fdb07f9b7a5e7e6669e6d69769d451
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jun 3 09:29:12 2022 -0400

    c++: don't substitute TEMPLATE_PARM_CONSTRAINTS [PR100374]

    This patch makes us avoid substituting into the TEMPLATE_PARM_CONSTRAINTS
    of each template parameter except as necessary for declaration matching,
    like we already do for the other constituent constraints of a declaration.

    This patch also improves the CA104 implementation of explicit
    specialization matching of a constrained function template inside a
    class template, by considering the function's combined constraints
    instead of just its trailing constraints.  This allows us to correctly
    handle the first three explicit specializations in concepts-spec2.C
    below, but because we compare the constraints as a whole, it means we
    incorrectly accept the fourth explicit specialization which writes #3's
    constraints in a different way.  For complete correctness here,
    determine_specialization should use tsubst_each_template_parm_constraints
    and template_parameter_heads_equivalent_p.

            PR c++/100374

    gcc/cp/ChangeLog:

            * pt.cc (determine_specialization): Compare overall constraints
            not just the trailing constraints.
            (tsubst_each_template_parm_constraints): Define.
            (tsubst_friend_function): Use it.
            (tsubst_friend_class): Use it.
            (tsubst_template_parm): Don't substitute TEMPLATE_PARM_CONSTRAINTS.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-spec2.C: New test.
            * g++.dg/cpp2a/concepts-template-parm11.C: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100374] Type-constraints of member function templates should not be substituted into during implicit instantiation
  2021-05-01 13:48 [Bug c++/100374] New: Type-constraints of member function templates should not be substituted into during implicit instantiation rs2740 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-06-03 13:29 ` cvs-commit at gcc dot gnu.org
@ 2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
  2022-07-21 16:49 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-21 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:90655e30130f8f609911335902db3c8354a5e21a

commit r12-8602-g90655e30130f8f609911335902db3c8354a5e21a
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jun 3 09:29:12 2022 -0400

    c++: don't substitute TEMPLATE_PARM_CONSTRAINTS [PR100374]

    This patch makes us avoid substituting into the TEMPLATE_PARM_CONSTRAINTS
    of each template parameter except as necessary for declaration matching,
    like we already do for the other constituent constraints of a declaration.

    This patch also improves the CA104 implementation of explicit
    specialization matching of a constrained function template inside a
    class template, by considering the function's combined constraints
    instead of just its trailing constraints.  This allows us to correctly
    handle the first three explicit specializations in concepts-spec2.C
    below, but because we compare the constraints as a whole, it means we
    incorrectly accept the fourth explicit specialization which writes #3's
    constraints in a different way.  For complete correctness here,
    determine_specialization should use tsubst_each_template_parm_constraints
    and template_parameter_heads_equivalent_p.

            PR c++/100374

    gcc/cp/ChangeLog:

            * pt.cc (determine_specialization): Compare overall constraints
            not just the trailing constraints.
            (tsubst_each_template_parm_constraints): Define.
            (tsubst_friend_function): Use it.
            (tsubst_friend_class): Use it.
            (tsubst_template_parm): Don't substitute TEMPLATE_PARM_CONSTRAINTS.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-spec2.C: New test.
            * g++.dg/cpp2a/concepts-template-parm11.C: New test.

    (cherry picked from commit 43c013df02fdb07f9b7a5e7e6669e6d69769d451)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100374] Type-constraints of member function templates should not be substituted into during implicit instantiation
  2021-05-01 13:48 [Bug c++/100374] New: Type-constraints of member function templates should not be substituted into during implicit instantiation rs2740 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
@ 2022-07-21 16:49 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-07-21 16:49 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.2
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.2/13

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-21 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-01 13:48 [Bug c++/100374] New: Type-constraints of member function templates should not be substituted into during implicit instantiation rs2740 at gmail dot com
2021-05-03 15:20 ` [Bug c++/100374] " ppalka at gcc dot gnu.org
2022-05-27 18:40 ` ppalka at gcc dot gnu.org
2022-06-03 13:29 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:48 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:49 ` 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).