public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100295] New: Internal compiler error from generic lambda capturing parameter pack and expanding it in if constexpr
@ 2021-04-27 18:44 davidfromonline at gmail dot com
  2021-04-28 12:30 ` [Bug c++/100295] " ppalka at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: davidfromonline at gmail dot com @ 2021-04-27 18:44 UTC (permalink / raw)
  To: gcc-bugs

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
```

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

end of thread, other threads:[~2023-05-22  3:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 18:44 [Bug c++/100295] New: Internal compiler error from generic lambda capturing parameter pack and expanding it in if constexpr davidfromonline at gmail dot com
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

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).