public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104641] New: Deduction guide for member template class rejected at class scope when used with typename dependant type
@ 2022-02-22 14:46 gcc at ebasoft dot com.pl
  2022-02-22 15:20 ` [Bug c++/104641] " ppalka at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gcc at ebasoft dot com.pl @ 2022-02-22 14:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104641
           Summary: Deduction guide for member template class rejected at
                    class scope when used with typename dependant type
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at ebasoft dot com.pl
  Target Milestone: ---

Follow up of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100983

Doesn't work when used with template typename inside template
https://godbolt.org/z/E6Pavhfza

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

* [Bug c++/104641] Deduction guide for member template class rejected at class scope when used with typename dependant type
  2022-02-22 14:46 [Bug c++/104641] New: Deduction guide for member template class rejected at class scope when used with typename dependant type gcc at ebasoft dot com.pl
@ 2022-02-22 15:20 ` ppalka at gcc dot gnu.org
  2022-02-22 16:04 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-02-22 15:20 UTC (permalink / raw)
  To: gcc-bugs

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

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
   Last reconfirmed|                            |2022-02-22
     Ever confirmed|0                           |1
                 CC|                            |ppalka at gcc dot gnu.org
         Depends on|                            |100983
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, this never worked.  Reduced rejects-valid testcase:

template<class T>
struct A {
  template<class U> struct B { B(U); };
};

template<class T>
void f() {
  typename A<T>::B x(0);
}

template void f<int>();


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100983
[Bug 100983] Deduction guide for member template class rejected at class scope

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

* [Bug c++/104641] Deduction guide for member template class rejected at class scope when used with typename dependant type
  2022-02-22 14:46 [Bug c++/104641] New: Deduction guide for member template class rejected at class scope when used with typename dependant type gcc at ebasoft dot com.pl
  2022-02-22 15:20 ` [Bug c++/104641] " ppalka at gcc dot gnu.org
@ 2022-02-22 16:04 ` ppalka at gcc dot gnu.org
  2022-03-12 20:02 ` cvs-commit at gcc dot gnu.org
  2022-03-12 20:08 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-02-22 16:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
One workaround is to use a helper member function (defined alongside the nested
class template) that performs the CTAD, something like:

#include <utility>

template<class T>
struct A {
  template<class U> struct B { B(U); };

  template<typename... Ts>
  static auto make_B(Ts&&... args) {
    return B(std::forward<Ts>(args)...);
  }
};

template<class T>
void f() {
  auto x = A<T>::make_B(0);
}

template void f<int>();

https://godbolt.org/z/vqjff9nbs

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

* [Bug c++/104641] Deduction guide for member template class rejected at class scope when used with typename dependant type
  2022-02-22 14:46 [Bug c++/104641] New: Deduction guide for member template class rejected at class scope when used with typename dependant type gcc at ebasoft dot com.pl
  2022-02-22 15:20 ` [Bug c++/104641] " ppalka at gcc dot gnu.org
  2022-02-22 16:04 ` ppalka at gcc dot gnu.org
@ 2022-03-12 20:02 ` cvs-commit at gcc dot gnu.org
  2022-03-12 20:08 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-12 20:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:d3b0dc686c00bfe9e7f4fe0490def68e9b92157a

commit r12-7633-gd3b0dc686c00bfe9e7f4fe0490def68e9b92157a
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sat Mar 12 15:00:51 2022 -0500

    c++: naming a dependently-scoped template for CTAD [PR104641]

    In order to be able to perform CTAD for a dependently-scoped template
    (such as A<T>::B in the testcase below), we need to permit a
    typename-specifier to resolve to a template as per [dcl.type.simple]/3,
    at least when it appears in a CTAD-enabled context.

    This patch implements this using a new tsubst flag tf_tst_ok to control
    when a TYPENAME_TYPE is allowed to name a template, and sets this flag
    when substituting into the type of a CAST_EXPR, CONSTRUCTOR or VAR_DECL
    (each of which is a CTAD-enabled context).

            PR c++/104641

    gcc/cp/ChangeLog:

            * cp-tree.h (tsubst_flags::tf_tst_ok): New flag.
            * decl.cc (make_typename_type): Allow a typename-specifier to
            resolve to a template when tf_tst_ok, in which case return
            a CTAD placeholder for the template.
            * pt.cc (tsubst_decl) <case VAR_DECL>: Set tf_tst_ok when
            substituting the type.
            (tsubst): Clear tf_tst_ok and remember if it was set.
            <case TYPENAME_TYPE>: Pass tf_tst_ok to make_typename_type
            appropriately.
            (tsubst_copy) <case CAST_EXPR>: Set tf_tst_ok when substituting
            the type.
            (tsubst_copy_and_build) <case CAST_EXPR>: Likewise.
            <case CONSTRUCTOR>: Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/class-deduction107.C: New test.

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

* [Bug c++/104641] Deduction guide for member template class rejected at class scope when used with typename dependant type
  2022-02-22 14:46 [Bug c++/104641] New: Deduction guide for member template class rejected at class scope when used with typename dependant type gcc at ebasoft dot com.pl
                   ` (2 preceding siblings ...)
  2022-03-12 20:02 ` cvs-commit at gcc dot gnu.org
@ 2022-03-12 20:08 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-03-12 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2022-03-12 20:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 14:46 [Bug c++/104641] New: Deduction guide for member template class rejected at class scope when used with typename dependant type gcc at ebasoft dot com.pl
2022-02-22 15:20 ` [Bug c++/104641] " ppalka at gcc dot gnu.org
2022-02-22 16:04 ` ppalka at gcc dot gnu.org
2022-03-12 20:02 ` cvs-commit at gcc dot gnu.org
2022-03-12 20:08 ` 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).