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

            Bug ID: 122739
           Summary: internal compiler error: crash at cp/pt.cc:30946 with
                    template parameter pack constructor after error
                    recovery
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-checking, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: attackerj1113 at gmail dot com
  Target Milestone: ---

The following code causes ICE/bailing out on x86-64 gcc since version 11.1 and
still reproducible on trunk:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<class> struct V1;

template<class> struct E {
  template<class... Fn> struct V : V1<Fn>::t... {
    V(Fn){}
 };
};

E<int>::V v = {};

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While Clang/EDG/MSVC reports error correctly.

Please check https://godbolt.org/z/h9dh3o1YY

As far as I understand, defining a template class with an unexpanded parameter
pack in its constructor and then instantiating it can trigger an ICE in
build_deduction_guide.

Compiler Output:
<source>:5:9: error: parameter packs not expanded with '...': [-Wtemplate-body]
    5 |     V(Fn){}
      |         ^
<source>:5:9: note:         'Fn'
<source>:9:16: internal compiler error: tree check: expected template_decl,
have error_mark in build_deduction_guide, at cp/pt.cc:30946
    9 | E<int>::V v = {};
      |                ^
0x29109c8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x290578b internal_error(char const*, ...)
        ???:0
0xa11af5 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0xd6e1fd do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int, tree_node*)
        ???:0
0xc11911 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xd475a3 c_parse_file()
        ???:0
0xeb6639 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