public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100983] New: Deduction guide for member template class rejected at class scope
@ 2021-06-09  4:45 brycelelbach at gmail dot com
  2021-06-09 12:04 ` [Bug c++/100983] " mpolacek at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: brycelelbach at gmail dot com @ 2021-06-09  4:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100983
           Summary: Deduction guide for member template class rejected at
                    class scope
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: brycelelbach at gmail dot com
  Target Milestone: ---

```
struct X {
  template <unsigned N>
  struct Y {
    template <typename... Ts>
    Y(Ts...) {}
  };

  template <typename... Ts>
  Y(Ts...) -> Y<sizeof...(Ts)>;
};
```

I'm fairly confident this is legal code, but GCC rejects it, stating that a
deduction guide is only allowed at namespace scope.

http://eel.is/c++draft/temp.deduct.guide#3.sentence-4 says:

"A deduction-guide shall inhabit the scope to which the corresponding class
template belongs and, for a member class template, have the same access."

... which suggests to me that it is allowed.

https://godbolt.org/z/cWa69scjW

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
@ 2021-06-09 12:04 ` mpolacek at gcc dot gnu.org
  2021-07-12 20:35 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-09 12:04 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=79501
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-06-09

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yeah, that should be valid.  I think it's the same problem observed in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79501#c3

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
  2021-06-09 12:04 ` [Bug c++/100983] " mpolacek at gcc dot gnu.org
@ 2021-07-12 20:35 ` cvs-commit at gcc dot gnu.org
  2021-08-11 20:06 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-12 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:8d75b8830e9dafb4e0c400c723653512adf40295

commit r12-2260-g8d75b8830e9dafb4e0c400c723653512adf40295
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Jul 12 16:35:18 2021 -0400

    c++: permit deduction guides at class scope [PR79501]

    This adds support for declaring (class-scope) deduction guides for a
    member class template.  Fortunately it seems only a couple of changes
    are needed in order for the existing CTAD machinery to handle them
    properly: we need to make sure to give them a FUNCTION_TYPE instead of a
    METHOD_TYPE, and we need to avoid using a BASELINK when looking them up.

            PR c++/79501
            PR c++/100983

    gcc/cp/ChangeLog:

            * decl.c (grokfndecl): Don't require that deduction guides are
            declared at namespace scope.  Check that class-scope deduction
            guides have the same access as the member class template.
            (grokdeclarator): Pretend class-scope deduction guides are static.
            * search.c (lookup_member): Don't use a BASELINK for (class-scope)
            deduction guides.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/class-deduction92.C: New test.
            * g++.dg/cpp1z/class-deduction93.C: New test.
            * g++.dg/cpp1z/class-deduction94.C: New test.
            * g++.dg/cpp1z/class-deduction95.C: New test.

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
  2021-06-09 12:04 ` [Bug c++/100983] " mpolacek at gcc dot gnu.org
  2021-07-12 20:35 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 20:06 ` ppalka at gcc dot gnu.org
  2022-02-22  8:06 ` gcc at ebasoft dot com.pl
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-08-11 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |12.0

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

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
                   ` (2 preceding siblings ...)
  2021-08-11 20:06 ` ppalka at gcc dot gnu.org
@ 2022-02-22  8:06 ` gcc at ebasoft dot com.pl
  2022-02-22 13:32 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gcc at ebasoft dot com.pl @ 2022-02-22  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

Artur Bać <gcc at ebasoft dot com.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at ebasoft dot com.pl

--- Comment #4 from Artur Bać <gcc at ebasoft dot com.pl> ---
trunk at compiler explorer still rejects valid code

https://godbolt.org/z/v4ebhj9Gh, only the message of requirement of namespace
scope is missing from gcc 11.2, invalid use of template-name without an
argument list

https://godbolt.org/z/7Wev6saWz "ctad" must be declared at namespace scope +
invalid use of template-name without an argument list

clang https://godbolt.org/z/vavPTbf36 works as expected

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
                   ` (3 preceding siblings ...)
  2022-02-22  8:06 ` gcc at ebasoft dot com.pl
@ 2022-02-22 13:32 ` ppalka at gcc dot gnu.org
  2022-02-22 13:40 ` gcc at ebasoft dot com.pl
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-02-22 13:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Artur Bać from comment #4)
> trunk at compiler explorer still rejects valid code
> 
> https://godbolt.org/z/v4ebhj9Gh, only the message of requirement of
> namespace scope is missing from gcc 11.2, invalid use of template-name
> without an argument list
> 
> https://godbolt.org/z/7Wev6saWz "ctad" must be declared at namespace scope +
> invalid use of template-name without an argument list

It works on trunk if you omit the dubious 'typename' before the template name:
https://godbolt.org/z/77M4dh3n5

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
                   ` (4 preceding siblings ...)
  2022-02-22 13:32 ` ppalka at gcc dot gnu.org
@ 2022-02-22 13:40 ` gcc at ebasoft dot com.pl
  2022-02-22 13:57 ` gcc at ebasoft dot com.pl
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gcc at ebasoft dot com.pl @ 2022-02-22 13:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Artur Bać <gcc at ebasoft dot com.pl> ---
The typename was from my real code by mistake where value_type s template
param.
But in real code withing template I have to use typename and it doesn't work
with trunk too.

https://godbolt.org/z/E6Pavhfza

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
                   ` (5 preceding siblings ...)
  2022-02-22 13:40 ` gcc at ebasoft dot com.pl
@ 2022-02-22 13:57 ` gcc at ebasoft dot com.pl
  2022-02-22 14:34 ` ppalka at gcc dot gnu.org
  2022-02-22 14:47 ` gcc at ebasoft dot com.pl
  8 siblings, 0 replies; 10+ messages in thread
From: gcc at ebasoft dot com.pl @ 2022-02-22 13:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Artur Bać <gcc at ebasoft dot com.pl> ---
Do I have to open new bug because of You marked it as fixed while it is not
fixed ?

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
                   ` (6 preceding siblings ...)
  2022-02-22 13:57 ` gcc at ebasoft dot com.pl
@ 2022-02-22 14:34 ` ppalka at gcc dot gnu.org
  2022-02-22 14:47 ` gcc at ebasoft dot com.pl
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-02-22 14:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Artur Bać from comment #7)
> Do I have to open new bug because of You marked it as fixed while it is not
> fixed ?

Yes please, it'd be easier to track that way.

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

* [Bug c++/100983] Deduction guide for member template class rejected at class scope
  2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
                   ` (7 preceding siblings ...)
  2022-02-22 14:34 ` ppalka at gcc dot gnu.org
@ 2022-02-22 14:47 ` gcc at ebasoft dot com.pl
  8 siblings, 0 replies; 10+ messages in thread
From: gcc at ebasoft dot com.pl @ 2022-02-22 14:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Artur Bać <gcc at ebasoft dot com.pl> ---
created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104641

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

end of thread, other threads:[~2022-02-22 14:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  4:45 [Bug c++/100983] New: Deduction guide for member template class rejected at class scope brycelelbach at gmail dot com
2021-06-09 12:04 ` [Bug c++/100983] " mpolacek at gcc dot gnu.org
2021-07-12 20:35 ` cvs-commit at gcc dot gnu.org
2021-08-11 20:06 ` ppalka at gcc dot gnu.org
2022-02-22  8:06 ` gcc at ebasoft dot com.pl
2022-02-22 13:32 ` ppalka at gcc dot gnu.org
2022-02-22 13:40 ` gcc at ebasoft dot com.pl
2022-02-22 13:57 ` gcc at ebasoft dot com.pl
2022-02-22 14:34 ` ppalka at gcc dot gnu.org
2022-02-22 14:47 ` gcc at ebasoft dot com.pl

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).