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

            Bug ID: 123680
           Summary: [16 Regression] ICE in type_has_nontrivial_copy_init
                    (at cp/tree.cc) during CTAD with lambda-NTTP default
                    argument
           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/jWjqeWo6G
The following c++ code crash gcc trunk with -std=c++20 flag.
But gcc 12,13,14,15 with checking is fine.

Code:
```cpp
template < auto B =
              [] {
                struct E {
                  E();
                };
                E();
              }>
struct A;
A x;
```

Stack dump:
```
<source>: In substitution of 'template<auto B> A() -> A<B> [with auto B =
<missing>]':
required from here
<source>:9:3:   
    9 | A x;
      |   ^
<source>:6:17: internal compiler error: in type_has_nontrivial_copy_init, at
cp/tree.cc:4842
    6 |                 E();
      |                 ^~~
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
0xe41a7d build_target_expr_with_type(tree_node*, tree_node*, int)
        ???:0
0xe6924d build_functional_cast(unsigned long, tree_node*, tree_node*, int)
        ???: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
0xb542c9 perform_dguide_overload_resolution(tree_node*, vec<tree_node*, va_gc,
vl_embed> const*, int)
        ???:0
0xd8ce97 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int, tree_node*)
        ???:0
0xc26d61 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???: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