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

            Bug ID: 123679
           Summary: [16 Regression] ICE in lookup_base (tree check:
                    expected record_type, have decltype_type) with
                    pointer-to-member access in nested 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/T5KdKPYMr
The following c++ code crash gcc trunk with -std=c++20 flag.
But 12,13,14,15 with checking is fine.


Code:
```cpp
class ConversionClass {
  void someMethod() {}
};

template <int T> struct bad {
  template <auto L =
                [] {
                  ConversionClass obj;
                  auto pmf = &ConversionClass::someMethod;
                  auto lambda = [&](auto &&obj) {
                    return [pmf, &obj]() { (obj.*pmf)(); };
                  };
                }>
  static void g() {
    L();
  }
};

template <class T> void f(T) { bad<0>::g(); }
```

Stack dump:
```
<source>: In substitution of 'template<auto L> static void bad<0>::g() [with
auto L = <missing>]':
required from here
<source>:19:41:   
   19 | template <class T> void f(T) { bad<0>::g(); }
      |                                ~~~~~~~~~^~
<source>:11:48: internal compiler error: tree check: expected record_type or
union_type or qual_union_type, have decltype_type in lookup_base, at
cp/search.cc:265
   11 |                     return [pmf, &obj]() { (obj.*pmf)(); };
      |                                            ~~~~^~~~~~
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
0xa234d1 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0xe68941 build_m_component_ref(tree_node*, tree_node*, int)
        ???:0
0xe471d1 build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node*, tree_node**, int)
        ???:0
0xd8f0de tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd8f0de tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd8f0de tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xda0531 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xdca851 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