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

            Bug ID: 123670
           Summary: [14/15/16 Regression] ICE (Segmentation fault) in
                    constraints_satisfied_p with lambda requires clause
                    referencing captured local lambda
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jirehguo at tju dot edu.cn
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/cdvv5hxKG
The following c++ code crash gcc trunk.
Goes back to 14.1 with checking.
Clang accepts the code.

Code:
```cpp
template <typename T>
void foo (T t) {
        auto g = [](int i) { return i * 2; };
        auto lambda = [&](auto x) -> int requires (sizeof(g(0)) > 0) { return
0;};
        lambda(42);
}       

int main()
{
  foo (1);
}
```

Stack dump:
```
<source>: In substitution of 'template<class auto:1>
foo<int>(int)::<lambda(auto:1)> [with auto:1 = int]':
required from 'void foo(T) [with T = int]'
<source>:5:15:   
    5 |         lambda(42);
      |         ~~~~~~^~~~
required from here
<source>:10:7:   
   10 |   foo (1);
      |   ~~~~^~~
<source>:4:52: internal compiler error: Segmentation fault
    4 |         auto lambda = [&](auto x) -> int requires (sizeof(g(0)) > 0) {
return 0;};
      |                                                    ^~~~~~~~~~~~
0x2950a78 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x294583b internal_error(char const*, ...)
        ???:0
0xbb2768 constraints_satisfied_p(tree_node*, tree_node*)
        ???:0
0xdca8b1 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0xb5ba92 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
        ???:0
0xe03535 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xdc7c3d instantiate_decl(tree_node*, bool, bool)
        ???:0
0xdd177a instantiate_pending_templates(int)
        ???:0
0xc3cd58 c_parse_final_cleanups()
        ???:0
0xeeed78 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

Reply via email to