public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
@ 2021-04-11 13:17 ppalka at gcc dot gnu.org
  2021-04-11 13:31 ` [Bug c++/100032] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-11 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100032
           Summary: renaming alias template that also adds cv-qualifiers
                    is deemed equivalent to underlying template
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppalka at gcc dot gnu.org
  Target Milestone: ---

DR 1286 allows alias templates to be equivalent to the underlying template if
the alias is just a renaming of the underlying template.  In the testcase
below, Z is arguably not equivalent to Y because of the added const qualifier,
but GCC still deems them equivalent, and accepts the testcase.

template <template<class> class> struct X { };
template <class> struct Y { };
template <class T> using Z = const Y<T>;
using T = X<Y>;
using T = X<Z>;

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

* [Bug c++/100032] [8/9/10/11 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
@ 2021-04-11 13:31 ` ppalka at gcc dot gnu.org
  2021-04-12  8:29 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-11 13:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |8.5
                 CC|                            |jason at gcc dot gnu.org
            Summary|renaming alias template     |[8/9/10/11 Regression]
                   |that also adds              |renaming alias template
                   |cv-qualifiers is deemed     |that also adds
                   |equivalent to underlying    |cv-qualifiers is deemed
                   |template                    |equivalent to underlying
                   |                            |template

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
We started accepting the testcase after r208152.

I tried making get_underlying_template look through an alias only if the
underlying type is unqualified:

--- a/gcc/cp/pt.c                                                               
+++ b/gcc/cp/pt.c                                                               
@@ -6574,6 +6574,8 @@ get_underlying_template (tree tmpl)                       
       /* The underlying type may have been ill-formed. Don't proceed.  */      
       if (!orig_type)                                                          
        break;                                                                  
+      if (TYPE_QUALS (orig_type) != TYPE_UNQUALIFIED)                          
+       break;                                                                  
       tree tinfo = TYPE_TEMPLATE_INFO_MAYBE_ALIAS (orig_type);                 
       if (!tinfo)                                                              
        break;                                                                  

but this also makes us (incorrectly?) reject

template <template<class> class> struct X { };
template <class> struct Y { };
template <class T> using Z = const Y<T>;
template <class T> using W = Z<T>;
using U = X<Z>;
using U = X<W>;

because the underlying type of W for some reason already has the const
qualifier, so get_underlying_template(W) yields W and we deem W not equivalent
to Z.

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

* [Bug c++/100032] [8/9/10/11 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
  2021-04-11 13:31 ` [Bug c++/100032] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
@ 2021-04-12  8:29 ` rguenth at gcc dot gnu.org
  2021-04-12 19:48 ` jason at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-12  8:29 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
           Priority|P3                          |P2

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

* [Bug c++/100032] [8/9/10/11 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
  2021-04-11 13:31 ` [Bug c++/100032] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
  2021-04-12  8:29 ` rguenth at gcc dot gnu.org
@ 2021-04-12 19:48 ` jason at gcc dot gnu.org
  2021-04-13 18:48 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-12 19:48 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-04-12
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #1)
> but this also makes us (incorrectly?) reject
> 
> template <template<class> class> struct X { };
> template <class> struct Y { };
> template <class T> using Z = const Y<T>;
> template <class T> using W = Z<T>;
> using U = X<Z>;
> using U = X<W>;
> 
> because the underlying type of W for some reason already has the const
> qualifier

Yes, because most alias templates are at least partly transparent, so W<T> has
the const added by Z<T>.  It should work to compare TYPE_QUALS to those of the
underlying template, rather than to TYPE_UNQUALIFIED.

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

* [Bug c++/100032] [8/9/10/11 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-04-12 19:48 ` jason at gcc dot gnu.org
@ 2021-04-13 18:48 ` jason at gcc dot gnu.org
  2021-04-13 19:20 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-13 18:48 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

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

* [Bug c++/100032] [8/9/10/11 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-04-13 18:48 ` jason at gcc dot gnu.org
@ 2021-04-13 19:20 ` cvs-commit at gcc dot gnu.org
  2021-04-14  0:37 ` [Bug c++/100032] [8/9/10 " jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-13 19:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:34ec63f1b5c2a4d39aa3b13ade96bcd44e294066

commit r11-8159-g34ec63f1b5c2a4d39aa3b13ade96bcd44e294066
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 13 14:49:29 2021 -0400

    c++: alias template equivalence and cv-quals [PR100032]

    We also need to check that the cv-qualifiers are the same.

    gcc/cp/ChangeLog:

            PR c++/100032
            * pt.c (get_underlying_template): Compare TYPE_QUALS.

    gcc/testsuite/ChangeLog:

            PR c++/100032
            * g++.dg/cpp0x/alias-decl-equiv1.C: New test.

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

* [Bug c++/100032] [8/9/10 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-04-13 19:20 ` cvs-commit at gcc dot gnu.org
@ 2021-04-14  0:37 ` jason at gcc dot gnu.org
  2021-05-14  9:54 ` [Bug c++/100032] [9/10 " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-14  0:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[8/9/10/11 Regression]      |[8/9/10 Regression]
                   |renaming alias template     |renaming alias template
                   |that also adds              |that also adds
                   |cv-qualifiers is deemed     |cv-qualifiers is deemed
                   |equivalent to underlying    |equivalent to underlying
                   |template                    |template
      Known to work|                            |11.0

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 11 so far.

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

* [Bug c++/100032] [9/10 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-04-14  0:37 ` [Bug c++/100032] [8/9/10 " jason at gcc dot gnu.org
@ 2021-05-14  9:54 ` jakub at gcc dot gnu.org
  2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.5                         |9.4

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.

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

* [Bug c++/100032] [9/10 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-05-14  9:54 ` [Bug c++/100032] [9/10 " jakub at gcc dot gnu.org
@ 2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
  2021-06-01  8:20 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-20 21:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:d83c30ec6c4865ca23a135c067eb9b56ac74a1f2

commit r10-9854-gd83c30ec6c4865ca23a135c067eb9b56ac74a1f2
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 13 14:49:29 2021 -0400

    c++: alias template equivalence and cv-quals [PR100032]

    We also need to check that the cv-qualifiers are the same.

    gcc/cp/ChangeLog:

            PR c++/100032
            * pt.c (get_underlying_template): Compare TYPE_QUALS.

    gcc/testsuite/ChangeLog:

            PR c++/100032
            * g++.dg/cpp0x/alias-decl-equiv1.C: New test.

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

* [Bug c++/100032] [9/10 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
@ 2021-06-01  8:20 ` rguenth at gcc dot gnu.org
  2022-05-13 17:40 ` cvs-commit at gcc dot gnu.org
  2022-05-13 17:42 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:20 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug c++/100032] [9/10 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-06-01  8:20 ` rguenth at gcc dot gnu.org
@ 2022-05-13 17:40 ` cvs-commit at gcc dot gnu.org
  2022-05-13 17:42 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13 17:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:945c2afcb390dd040510ee7a2dc996ad204031c5

commit r9-10162-g945c2afcb390dd040510ee7a2dc996ad204031c5
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 13 14:49:29 2021 -0400

    c++: alias template equivalence and cv-quals [PR100032]

    We also need to check that the cv-qualifiers are the same.

    gcc/cp/ChangeLog:

            PR c++/100032
            * pt.c (get_underlying_template): Compare TYPE_QUALS.

    gcc/testsuite/ChangeLog:

            PR c++/100032
            * g++.dg/cpp0x/alias-decl-equiv1.C: New test.

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

* [Bug c++/100032] [9/10 Regression] renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template
  2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2022-05-13 17:40 ` cvs-commit at gcc dot gnu.org
@ 2022-05-13 17:42 ` jason at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-13 17:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 9.5/10.4/11.

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

end of thread, other threads:[~2022-05-13 17:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-11 13:17 [Bug c++/100032] New: renaming alias template that also adds cv-qualifiers is deemed equivalent to underlying template ppalka at gcc dot gnu.org
2021-04-11 13:31 ` [Bug c++/100032] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
2021-04-12  8:29 ` rguenth at gcc dot gnu.org
2021-04-12 19:48 ` jason at gcc dot gnu.org
2021-04-13 18:48 ` jason at gcc dot gnu.org
2021-04-13 19:20 ` cvs-commit at gcc dot gnu.org
2021-04-14  0:37 ` [Bug c++/100032] [8/9/10 " jason at gcc dot gnu.org
2021-05-14  9:54 ` [Bug c++/100032] [9/10 " jakub at gcc dot gnu.org
2021-05-20 21:35 ` cvs-commit at gcc dot gnu.org
2021-06-01  8:20 ` rguenth at gcc dot gnu.org
2022-05-13 17:40 ` cvs-commit at gcc dot gnu.org
2022-05-13 17:42 ` jason 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).