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

            Bug ID: 123668
           Summary: [14/15/16 Regression] ICE in convert_nontype_argument
                    when passing a lambda as an explicit template argument
                    to a member function template
           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/cbTj9E3vG
The following c++ code crash gcc trunk.
Goes back to 14.1 with checking.
But clang accepts the code.

Code:
```cpp
template <auto = [] {}> static void f();
template <int N> struct bad {
  template <auto L = [] {}> static void g();
};
void foo(int i) {
  auto lambda = []() { return 1; };
  auto nestedLambda = []() { return 1; };
  bad<0>::g();
  bad<0>::g<[] {}>();
}
```

Stack dump:
```
<source>: In function 'void foo(int)':
<source>:9:19: internal compiler error: in convert_nontype_argument, at
cp/pt.cc:8049
    9 |   bad<0>::g<[] {}>();
      |   ~~~~~~~~~~~~~~~~^~
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
0xb1ec34 fancy_abort(char const*, int, char const*)
        ???:0
0xdaf713 coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
        ???:0
0xdca483 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
        ???:0
0xb403cb build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ???:0
0xe02c73 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xd64c03 c_parse_file()
        ???:0
0xeeed49 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