public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/93595] [c++20] Substitution failure of "auto = []{}" in template parameter list in nested template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-20  6:12 ` pinskia at gcc dot gnu.org
  2021-12-20  6:12 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-20  6:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lutztonineubert at gmail dot com

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 97610 has been marked as a duplicate of this bug. ***

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

* [Bug c++/93595] [c++20] Substitution failure of "auto = []{}" in template parameter list in nested template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
  2021-12-20  6:12 ` [Bug c++/93595] [c++20] Substitution failure of "auto = []{}" in template parameter list in nested template context pinskia at gcc dot gnu.org
@ 2021-12-20  6:12 ` pinskia at gcc dot gnu.org
  2021-12-20  6:55 ` [Bug c++/93595] [c++20] function call, substitution failure of template paramter with a lambda default in " pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-20  6:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/93595] [c++20] function call, substitution failure of template paramter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
  2021-12-20  6:12 ` [Bug c++/93595] [c++20] Substitution failure of "auto = []{}" in template parameter list in nested template context pinskia at gcc dot gnu.org
  2021-12-20  6:12 ` pinskia at gcc dot gnu.org
@ 2021-12-20  6:55 ` pinskia at gcc dot gnu.org
  2023-07-11 13:42 ` ppalka at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-20  6:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |barry.revzin at gmail dot com

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 102644 has been marked as a duplicate of this bug. ***

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

* [Bug c++/93595] [c++20] function call, substitution failure of template paramter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-12-20  6:55 ` [Bug c++/93595] [c++20] function call, substitution failure of template paramter with a lambda default in " pinskia at gcc dot gnu.org
@ 2023-07-11 13:42 ` ppalka at gcc dot gnu.org
  2023-07-11 14:42 ` ted at lyncon dot se
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-07-11 13:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ted at lyncon dot se

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 110604 has been marked as a duplicate of this bug. ***

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

* [Bug c++/93595] [c++20] function call, substitution failure of template paramter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2023-07-11 13:42 ` ppalka at gcc dot gnu.org
@ 2023-07-11 14:42 ` ted at lyncon dot se
  2023-07-11 14:44 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: ted at lyncon dot se @ 2023-07-11 14:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Ted Lyngmo <ted at lyncon dot se> ---
@Andrew Pinski: Shouldn't the status be "CONFIRMED" rather than "NEW"?

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

* [Bug c++/93595] [c++20] function call, substitution failure of template paramter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2023-07-11 14:42 ` ted at lyncon dot se
@ 2023-07-11 14:44 ` pinskia at gcc dot gnu.org
  2023-07-11 14:46 ` ted at lyncon dot se
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-11 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Ted Lyngmo from comment #6)
> @Andrew Pinski: Shouldn't the status be "CONFIRMED" rather than "NEW"?

There is status called confirmed but rather rhe new status is the confirmed
state.

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

* [Bug c++/93595] [c++20] function call, substitution failure of template paramter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2023-07-11 14:44 ` pinskia at gcc dot gnu.org
@ 2023-07-11 14:46 ` ted at lyncon dot se
  2024-03-25 10:55 ` [Bug c++/93595] [c++20] function call, substitution failure of template parameter " andrea.agostini.sax at gmail dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: ted at lyncon dot se @ 2023-07-11 14:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Ted Lyngmo <ted at lyncon dot se> ---
:-) Ok I tried understanding the Status by reading
https://gcc.gnu.org/bugzilla/page.cgi?id=fields.html#bug_status but it doesn't
mention NEW. But ok, as long as it's actually a confirmed bug, I'm good.

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

* [Bug c++/93595] [c++20] function call, substitution failure of template parameter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2023-07-11 14:46 ` ted at lyncon dot se
@ 2024-03-25 10:55 ` andrea.agostini.sax at gmail dot com
  2024-03-25 19:05 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: andrea.agostini.sax at gmail dot com @ 2024-03-25 10:55 UTC (permalink / raw)
  To: gcc-bugs

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

Andrea Agostini <andrea.agostini.sax at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrea.agostini.sax at gmail dot c
                   |                            |om

--- Comment #9 from Andrea Agostini <andrea.agostini.sax at gmail dot com> ---
While trying to work around this, I massaged the code enough for the compiler
to produce a more interesting message: see https://godbolt.org/z/Gsbv8fG7M

Adding a return statement to the lambda makes the compiler confess that it
thinks the lambda should return int, rather than void. Maybe this can help
pinpoint the bug?

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

* [Bug c++/93595] [c++20] function call, substitution failure of template parameter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2024-03-25 10:55 ` [Bug c++/93595] [c++20] function call, substitution failure of template parameter " andrea.agostini.sax at gmail dot com
@ 2024-03-25 19:05 ` ppalka at gcc dot gnu.org
  2024-04-12 19:21 ` ppalka at gcc dot gnu.org
  2024-04-12 19:21 ` ppalka at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-25 19:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/93595] [c++20] function call, substitution failure of template parameter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2024-03-25 19:05 ` ppalka at gcc dot gnu.org
@ 2024-04-12 19:21 ` ppalka at gcc dot gnu.org
  2024-04-12 19:21 ` ppalka at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-12 19:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:081c1e93d56d35c7314ed68e6d87628b430de917

commit r14-9938-081c1e93d56d35c7314ed68e6d87628b430de917
Author: Patrick Palka <ppalka@redhat.com>

c++: templated substitution into lambda-expr [PR114393]

The below testcases use a lambda-expr as a template argument and they
all trip over the below added tsubst_lambda_expr sanity check ultimately
because current_template_parms is empty which causes push_template_decl
to return error_mark_node from the call to begin_lambda_type.  Were it
not for the sanity check this silent error_mark_node result leads to
nonsensical errors down the line, or silent breakage.

In the first testcase, we hit this assert during instantiation of the
dependent alias template-id c1_t<_Data> from instantiate_template, which
clears current_template_parms via push_to_top_level.  Similar story for
the second testcase.  For the third testcase we hit the assert during
partial instantiation of the member template from instantiate_class_template
which similarly calls push_to_top_level.

These testcases illustrate that templated substitution into a lambda-expr
is not always possible, in particular when we lost the relevant template
context.  I experimented with recovering the template context by making
tsubst_lambda_expr fall back to using scope_chain->prev->template_parms if
current_template_parms is empty which worked but seemed like a hack.  I
also experimented with preserving the template context by keeping
current_template_parms set during instantiate_template for a dependent
specialization which also worked but it's at odds with the fact that we
cache dependent specializations (and so they should be independent of
the template context).

So instead of trying to make such substitution work, this patch uses the
extra-args mechanism to defer templated substitution into a lambda-expr
when we lost the relevant template context.

        PR c++/114393
        PR c++/107457
        PR c++/93595

gcc/cp/ChangeLog:

        * cp-tree.h (LAMBDA_EXPR_EXTRA_ARGS): Define.
        (tree_lambda_expr::extra_args): New field.
        * module.cc (trees_out::core_vals) <case LAMBDA_EXPR>: Stream
        LAMBDA_EXPR_EXTRA_ARGS.
        (trees_in::core_vals) <case LAMBDA_EXPR>: Likewise.
        * pt.cc (has_extra_args_mechanism_p): Return true for LAMBDA_EXPR.
        (tree_extra_args): Handle LAMBDA_EXPR.
        (tsubst_lambda_expr): Use LAMBDA_EXPR_EXTRA_ARGS to defer templated
        substitution into a lambda-expr if we lost the template context.
        Add sanity check for error_mark_node result from begin_lambda_type.

gcc/testsuite/ChangeLog:

        * g++.dg/cpp2a/lambda-targ2.C: New test.
        * g++.dg/cpp2a/lambda-targ3.C: New test.
        * g++.dg/cpp2a/lambda-targ4.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>

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

* [Bug c++/93595] [c++20] function call, substitution failure of template parameter with a lambda default in template context
       [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2024-04-12 19:21 ` ppalka at gcc dot gnu.org
@ 2024-04-12 19:21 ` ppalka at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-12 19:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2024-04-12 19:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-93595-4@http.gcc.gnu.org/bugzilla/>
2021-12-20  6:12 ` [Bug c++/93595] [c++20] Substitution failure of "auto = []{}" in template parameter list in nested template context pinskia at gcc dot gnu.org
2021-12-20  6:12 ` pinskia at gcc dot gnu.org
2021-12-20  6:55 ` [Bug c++/93595] [c++20] function call, substitution failure of template paramter with a lambda default in " pinskia at gcc dot gnu.org
2023-07-11 13:42 ` ppalka at gcc dot gnu.org
2023-07-11 14:42 ` ted at lyncon dot se
2023-07-11 14:44 ` pinskia at gcc dot gnu.org
2023-07-11 14:46 ` ted at lyncon dot se
2024-03-25 10:55 ` [Bug c++/93595] [c++20] function call, substitution failure of template parameter " andrea.agostini.sax at gmail dot com
2024-03-25 19:05 ` ppalka at gcc dot gnu.org
2024-04-12 19:21 ` ppalka at gcc dot gnu.org
2024-04-12 19:21 ` 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).