public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected
@ 2022-01-19  0:21 pinskia at gcc dot gnu.org
  2022-01-19  0:21 ` [Bug c++/104108] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-19  0:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104108
           Summary: [10/11/12 Regression] template alias inside template
                    with static field of template class rejected
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take which I accidently reduced from PR 104107:
template<template<const int&> typename tt_w_data>
struct tt_main {
  static int m_parameter;
  template<template<const int&> typename t_data> using t_make 
    = t_data<m_parameter>;
};

This should be valid code but currently we reject it with:
<source>:5:25: error: '& tt_main<tt_w_data>::m_parameter' is not a valid
template argument of type 'const int&' because
'tt_main<tt_w_data>::m_parameter' is not a variable
    5 |     = t_data<m_parameter>;
      |                         ^

I don't see how tt_main<tt_w_data>::m_parameter is not a variable because it
looks like one to me.

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

* [Bug c++/104108] [10/11/12 Regression] template alias inside template with static field of template class rejected
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
@ 2022-01-19  0:21 ` pinskia at gcc dot gnu.org
  2022-01-19  0:42 ` [Bug c++/104108] [10/11/12 Regression] [c++17+] " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-19  0:21 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.4

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the problem here is definitely different from PR 104107 as that one ICEs
with GCC 9 while this one starts to be rejected in GCC 10.

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

* [Bug c++/104108] [10/11/12 Regression] [c++17+] template alias inside template with static field of template class rejected
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
  2022-01-19  0:21 ` [Bug c++/104108] " pinskia at gcc dot gnu.org
@ 2022-01-19  0:42 ` pinskia at gcc dot gnu.org
  2022-01-19  8:28 ` [Bug c++/104108] [10/11/12 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832 marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-19  0:42 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 Regression]       |[10/11/12 Regression]
                   |template alias inside       |[c++17+] template alias
                   |template with static field  |inside template with static
                   |of template class rejected  |field of template class
                   |                            |rejected

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Ok, this is only rejected for -std=c++17 and -std=c++20 :).

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

* [Bug c++/104108] [10/11/12 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
  2022-01-19  0:21 ` [Bug c++/104108] " pinskia at gcc dot gnu.org
  2022-01-19  0:42 ` [Bug c++/104108] [10/11/12 Regression] [c++17+] " pinskia at gcc dot gnu.org
@ 2022-01-19  8:28 ` marxin at gcc dot gnu.org
  2022-01-19 10:57 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-01-19  8:28 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-19
             Status|UNCONFIRMED                 |NEW
            Summary|[10/11/12 Regression]       |[10/11/12 Regression]
                   |[c++17+] template alias     |[c++17+] template alias
                   |inside template with static |inside template with static
                   |field of template class     |field of template class
                   |rejected                    |rejected since
                   |                            |r10-6329-g423284053ec51832
     Ever confirmed|0                           |1
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r10-6329-g423284053ec51832.

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

* [Bug c++/104108] [10/11/12 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-01-19  8:28 ` [Bug c++/104108] [10/11/12 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832 marxin at gcc dot gnu.org
@ 2022-01-19 10:57 ` rguenth at gcc dot gnu.org
  2022-01-19 14:57 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-19 10:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/104108] [10/11/12 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-01-19 10:57 ` rguenth at gcc dot gnu.org
@ 2022-01-19 14:57 ` mpolacek at gcc dot gnu.org
  2022-03-08 22:50 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-01-19 14:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/104108] [10/11/12 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-01-19 14:57 ` mpolacek at gcc dot gnu.org
@ 2022-03-08 22:50 ` cvs-commit at gcc dot gnu.org
  2022-03-08 22:51 ` [Bug c++/104108] [10/11 " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-08 22:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

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

commit r12-7548-gd54ce4641ed106666208be36fd514cae8ff1153c
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Mar 8 13:55:15 2022 -0500

    c++: Wrong error with alias template in class tmpl [PR104108]

    In r10-6329 I tried to optimize the number of calls to v_d_e_p in
    convert_nontype_argument by remembering whether the expression was
    value-dependent in a bool flag.  I did that wrongly assuming that its
    value-dependence will not be changed by build_converted_constant_expr.
    This testcase shows that it can: b_c_c_e gets a VAR_DECL for m_parameter,
    which is not value-dependent, but we're converting it to "const int &"
    so it returns

      (const int &)(const int *) &m_parameter

    which suddenly becomes value-dependent because of the added ADDR_EXPR:
    has_value_dependent_address is now true because m_parameter's context S<T>
    is dependent.  With this bug in place, we went to the second branch here:

          if (TYPE_REF_OBJ_P (TREE_TYPE (expr)) && val_dep_p)
            /* OK, dependent reference.  We don't want to ask whether a DECL is
               itself value-dependent, since what we want here is its address. 
*/;
          else
            {
              expr = build_address (expr);

              if (invalid_tparm_referent_p (type, expr, complain))
                return NULL_TREE;
            }

    wherein build_address created a bad tree and then i_t_r_p complained.

            PR c++/104108

    gcc/cp/ChangeLog:

            * pt.cc (convert_nontype_argument): Recompute
            value_dependent_expression_p after build_converted_constant_expr.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/alias-decl-74.C: New test.

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

* [Bug c++/104108] [10/11 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-03-08 22:50 ` cvs-commit at gcc dot gnu.org
@ 2022-03-08 22:51 ` mpolacek at gcc dot gnu.org
  2022-03-29  1:45 ` cvs-commit at gcc dot gnu.org
  2022-03-29  1:48 ` [Bug c++/104108] [10 " mpolacek at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-03-08 22:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 Regression]       |[10/11 Regression] [c++17+]
                   |[c++17+] template alias     |template alias inside
                   |inside template with static |template with static field
                   |field of template class     |of template class rejected
                   |rejected since              |since
                   |r10-6329-g423284053ec51832  |r10-6329-g423284053ec51832

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far.

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

* [Bug c++/104108] [10/11 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-03-08 22:51 ` [Bug c++/104108] [10/11 " mpolacek at gcc dot gnu.org
@ 2022-03-29  1:45 ` cvs-commit at gcc dot gnu.org
  2022-03-29  1:48 ` [Bug c++/104108] [10 " mpolacek at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-29  1:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:58e08fb6ffd0842c7b813eb7122fe8660df33bf1

commit r11-9712-g58e08fb6ffd0842c7b813eb7122fe8660df33bf1
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Mar 8 13:55:15 2022 -0500

    c++: Wrong error with alias template in class tmpl [PR104108]

    In r10-6329 I tried to optimize the number of calls to v_d_e_p in
    convert_nontype_argument by remembering whether the expression was
    value-dependent in a bool flag.  I did that wrongly assuming that its
    value-dependence will not be changed by build_converted_constant_expr.
    This testcase shows that it can: b_c_c_e gets a VAR_DECL for m_parameter,
    which is not value-dependent, but we're converting it to "const int &"
    so it returns

      (const int &)(const int *) &m_parameter

    which suddenly becomes value-dependent because of the added ADDR_EXPR:
    has_value_dependent_address is now true because m_parameter's context S<T>
    is dependent.  With this bug in place, we went to the second branch here:

          if (TYPE_REF_OBJ_P (TREE_TYPE (expr)) && val_dep_p)
            /* OK, dependent reference.  We don't want to ask whether a DECL is
               itself value-dependent, since what we want here is its address. 
*/;
          else
            {
              expr = build_address (expr);

              if (invalid_tparm_referent_p (type, expr, complain))
                return NULL_TREE;
            }

    wherein build_address created a bad tree and then i_t_r_p complained.

            PR c++/104108

    gcc/cp/ChangeLog:

            * pt.c (convert_nontype_argument): Recompute
            value_dependent_expression_p after build_converted_constant_expr.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/alias-decl-74.C: New test.

    (cherry picked from commit d54ce4641ed106666208be36fd514cae8ff1153c)

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

* [Bug c++/104108] [10 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832
  2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-03-29  1:45 ` cvs-commit at gcc dot gnu.org
@ 2022-03-29  1:48 ` mpolacek at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-03-29  1:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11 Regression] [c++17+] |[10 Regression] [c++17+]
                   |template alias inside       |template alias inside
                   |template with static field  |template with static field
                   |of template class rejected  |of template class rejected
                   |since                       |since
                   |r10-6329-g423284053ec51832  |r10-6329-g423284053ec51832
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-03-29  1:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19  0:21 [Bug c++/104108] New: [10/11/12 Regression] template alias inside template with static field of template class rejected pinskia at gcc dot gnu.org
2022-01-19  0:21 ` [Bug c++/104108] " pinskia at gcc dot gnu.org
2022-01-19  0:42 ` [Bug c++/104108] [10/11/12 Regression] [c++17+] " pinskia at gcc dot gnu.org
2022-01-19  8:28 ` [Bug c++/104108] [10/11/12 Regression] [c++17+] template alias inside template with static field of template class rejected since r10-6329-g423284053ec51832 marxin at gcc dot gnu.org
2022-01-19 10:57 ` rguenth at gcc dot gnu.org
2022-01-19 14:57 ` mpolacek at gcc dot gnu.org
2022-03-08 22:50 ` cvs-commit at gcc dot gnu.org
2022-03-08 22:51 ` [Bug c++/104108] [10/11 " mpolacek at gcc dot gnu.org
2022-03-29  1:45 ` cvs-commit at gcc dot gnu.org
2022-03-29  1:48 ` [Bug c++/104108] [10 " mpolacek 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).