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

            Bug ID: 124561
           Summary: ICE in tsubst on invalid out-of-class definition of
                    member class template
           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 on x86-64 gcc on trunk (since 6.1):


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename T>
struct C {
  template<int> struct F;
};

using X = C<int>;

template<typename T>//crash
//template<>        //ok
template<int I>
struct X::F {};

X::F<42> f;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please check https://godbolt.org/z/Tn3Pe7aKE for more info

GCC ICEs in tsubst when instantiating C<int>::F<42> if the member class
template template<int> struct C<T>::F; is given an ill-formed out-of-class
definition.

Compiler Output:

<source>: In instantiation of 'struct C<int>::F<42>':
<source>:12:10:   required from here
   12 | X::F<42> f;
      |          ^
<source>:10:13: internal compiler error: in tsubst, at cp/pt.cc:17141
   10 | struct X::F {};
      |             ^
0x2966218 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x295ae5b internal_error(char const*, ...)
        ???:0
0xb21e56 fancy_abort(char const*, int, char const*)
        ???:0
0xdb30b9 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xdb32b1 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xda68bf tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xda6bd2 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xdd8c92 instantiate_class_template(tree_node*)
        ???:0
0xbfc51d start_decl_1(tree_node*, bool)
        ???:0
0xc20e0d start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ???:0
0xd6e1f3 c_parse_file()
        ???:0
0xef8709 c_common_parse_file()
        ???:0
/cefs/78/78f337d75e00219ede7494e2_gcc-trunk-20260317/bin/../libexec/gcc/x86_64-linux-gnu/16.0.1/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/78/78f337d75e00219ede7494e2_gcc-trunk-20260317/bin/../lib/gcc/x86_64-linux-gnu/16.0.1/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -fdiagnostics-color=always
-fno-verbose-asm -o /app/output.s
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
  • [Bug c++/124561] New: ICE in t... attackerj1113 at gmail dot com via Gcc-bugs

Reply via email to