public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "davidfromonline at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/100295] New: Internal compiler error from generic lambda capturing parameter pack and expanding it in if constexpr
Date: Tue, 27 Apr 2021 18:44:53 +0000	[thread overview]
Message-ID: <bug-100295-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 100295
           Summary: Internal compiler error from generic lambda capturing
                    parameter pack and expanding it in if constexpr
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: davidfromonline at gmail dot com
  Target Milestone: ---

The following well-formed translation unit

```
template<typename... Ts>
void f(Ts... ts) {
        auto lambda = [=](auto x) {
                if constexpr (sizeof((..., ts), x) != 0) {
                        (..., ts);
                }
        };
        lambda(0);
}

void g() {
        f(0);
}
```

causes gcc to crash with

```
<source>: In instantiation of ‘f<int>(int)::<lambda(auto:1)> [with auto:1 =
int]’:
<source>:8:8:   required from ‘void f(Ts ...) [with Ts = {int}]’
<source>:12:3:   required from here
<source>:5:31: internal compiler error: trying to capture ‘ts#0’ in
instantiation of generic lambda
    5 |                         (..., ts);
      |                               ^~
0x9c9318 add_capture(tree_node*, tree_node*, tree_node*, bool, bool)
        ../../source/gcc/cp/lambda.c:637
0x9c9391 add_default_capture(tree_node*, tree_node*, tree_node*)
        ../../source/gcc/cp/lambda.c:697
0xaa68ef tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:20834
0xaa3ea8 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:20949
0xaaf3d7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:19204
0xaae9d1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18229
0xaae9d1 gen_elem_of_pack_expansion_instantiation
        ../../source/gcc/cp/pt.c:12568
0xaae9d1 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
        ../../source/gcc/cp/pt.c:13233
0xaa163f tsubst_fold_expr_pack
        ../../source/gcc/cp/pt.c:12646
0xaa163f tsubst_unary_left_fold
        ../../source/gcc/cp/pt.c:12685
0xaa163f tsubst_copy
        ../../source/gcc/cp/pt.c:17343
0xaa56f2 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:20962
0xaaf3d7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:19204
0xab11f9 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18274
0xab0aa3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18595
0xab4503 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18564
0xab0aa3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18595
0xab0aa3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18595
0xab8308 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18229
0xab8308 instantiate_body
        ../../source/gcc/cp/pt.c:25921
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

             reply	other threads:[~2021-04-27 18:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 18:44 davidfromonline at gmail dot com [this message]
2021-04-28 12:30 ` [Bug c++/100295] " ppalka at gcc dot gnu.org
2021-10-21  4:21 ` pinskia at gcc dot gnu.org
2021-10-21  4:22 ` pinskia at gcc dot gnu.org
2022-08-24  1:50 ` pinskia at gcc dot gnu.org
2022-12-03  9:08 ` pinskia at gcc dot gnu.org
2022-12-15 21:03 ` cvs-commit at gcc dot gnu.org
2022-12-15 21:04 ` ppalka at gcc dot gnu.org
2022-12-19 16:54 ` cvs-commit at gcc dot gnu.org
2023-02-17 13:24 ` ppalka at gcc dot gnu.org
2023-05-22  3:12 ` cvs-commit at gcc dot gnu.org
2023-05-22  3:15 ` ppalka at gcc dot gnu.org

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-100295-4@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).