public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ppalka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/114393] [14 regression] over eager "invalid use of void expression" ? since r14-2170-g4cf64d9cc2faf4
Date: Fri, 12 Apr 2024 19:09:17 +0000	[thread overview]
Message-ID: <bug-114393-4-UzyDmPA2YJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114393-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 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:d74fe10b13336b9de2e025ced4af00a25ff1d3e7

commit r14-9943-d74fe10b13336b9de2e025ced4af00a25ff1d3e7
Author: Patrick Palka <ppalka@redhat.com>

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

The original PR114393 testcase is unfortunately still not accepted after
r14-9938-g081c1e93d56d35 due to return type deduction confusion when a
lambda-expr is used as a default template argument.

The below reduced testcase demonstrates the bug.  Here when forming the
dependent specialization b_v<U> we substitute the default argument of F,
a lambda-expr, with _Descriptor=U.  (In this case in_template_context is
true since we're in the context of the template c_v, so we don't defer.)
This substitution in turn lowers the level of the lambda's auto return
type from 2 to 1 and so later, when instantiating c_v<int, char> we wrongly
substitute this auto with the template argument at level=0,index=0, i.e.
int, instead of going through do_auto_deduction which would yield char.

One way to fix this would be to use a level-less auto to represent a
deduced return type of a lambda, but that might be too invasive of a
change at this stage, and it might be better to do this across the board
for all deduced return types.

Another way would be to pass tf_partial from coerce_template_parms during
dependent substitution into a default template argument so that the
substitution doesn't do any level-lowering, but that wouldn't do the right
thing in this case due to the tf_partial early exit in the LAMBDA_EXPR
case of tsubst_expr.

Yet another way, and the approach that this patch takes, is to just
defer all dependent substitution into a lambda-expr, building upon the
logic added in r14-9938-g081c1e93d56d35.  This also helps ensure
LAMBDA_EXPR_REGEN_INFO consists only of the concrete template arguments
that were ultimately substituted into the most general lambda.

        PR c++/114393

gcc/cp/ChangeLog:

        * pt.cc (tsubst_lambda_expr): Also defer all dependent
        substitution.

gcc/testsuite/ChangeLog:

        * g++.dg/cpp2a/lambda-targ2a.C: New test.

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

  parent reply	other threads:[~2024-04-12 19:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19 11:09 [Bug c++/114393] New: over eager "invalid use of void expression" ? prlw1 at cam dot ac.uk
2024-03-19 11:29 ` [Bug c++/114393] [14 regression] " redi at gcc dot gnu.org
2024-03-19 11:32 ` redi at gcc dot gnu.org
2024-03-19 11:56 ` [Bug c++/114393] [14 regression] over eager "invalid use of void expression" ? since r14-2170-g4cf64d9cc2faf4 rguenth at gcc dot gnu.org
2024-03-19 22:42 ` pinskia at gcc dot gnu.org
2024-03-20  3:51 ` pinskia at gcc dot gnu.org
2024-03-20  4:04 ` pinskia at gcc dot gnu.org
2024-03-25 19:05 ` ppalka at gcc dot gnu.org
2024-03-29 23:49 ` law at gcc dot gnu.org
2024-04-12 19:08 ` ppalka at gcc dot gnu.org
2024-04-12 19:09 ` ppalka at gcc dot gnu.org [this message]
2024-04-12 19:11 ` ppalka at gcc dot gnu.org
2024-04-14 19:27 ` prlw1 at cam dot ac.uk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114393-4-UzyDmPA2YJ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).