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

            Bug ID: 120126
           Summary: Title: ICE in GCC with pack-dependent decltype in
                    lambda: cp_type_quals
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mario.rodriguezb1 at um dot es
  Target Milestone: ---

GCC crashes when deducing the type of a lambda-captured pack using
decltype(args) inside a lambda body.

```
#include <iostream>
#include <functional>
template <typename... Args>
auto sum(Args... args){
        return [args...] {
                typename std::remove_reference<decltype(args)>::type
temp{std::move(args)...};
        };
}
int main() {
  auto min = sum(1, 10);
}
```

Stack dump

```
<source>:6:70: internal compiler error: Segmentation fault
    6 |                 typename std::remove_reference<decltype(args)>::type
temp{std::move(args)...};
      |                                                                     
^~~~
0x2031cbc internal_error(char const*, ...)
        ???:0
0x98c804 cp_type_quals(tree_node const*)
        ???:0
0x939b30 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x93cea7 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x939b7e tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x9448a6 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x93247f instantiate_decl(tree_node*, bool, bool)
        ???:0
0x8320b7 maybe_instantiate_decl(tree_node*)
        ???:0
0x833277 mark_used(tree_node*, int)
        ???:0
0x7a0efe build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0x960f4a finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0x90ee14 c_parse_file()
        ???:0
0xa0d1b9 c_common_parse_file()
        ???:0
```

To reproduce:

Happens until 14.2

https://gcc.godbolt.org/z/116K67dhe

Reply via email to