https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84611
Bug ID: 84611 Summary: internal compiler error: in operator[], at vec.h:826 (local_class_index()) Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vegard.nossum at gmail dot com Target Milestone: --- Input: template<typename = int> struct a { a() { struct c; try { } catch (struct c {}) { } } }; struct d { d(); a<> b; }; d::d() {}; Output: xgcc -x c++ -c input.cc input.cc: In constructor 'a< <template-parameter-1-1> >::a()': input.cc:6:23: error: types may not be defined in exception-declarations } catch (struct c {}) { ^ input.cc: In instantiation of 'a< <template-parameter-1-1> >::a() [with <template-parameter-1-1> = int]': input.cc:16:6: required from here input.cc:6:24: error: conflicting declaration 'struct a< <template-parameter-1-1> >::a() [with <template-parameter-1-1> = int]::c' } catch (struct c {}) { ^ input.cc:4:12: note: previous declaration as 'struct a< <template-parameter-1-1> >::a() [with <template-parameter-1-1> = int]::c' struct c; ^ input.cc:6:7: internal compiler error: in operator[], at vec.h:826 } catch (struct c {}) { ^~~~~ 0xd70ab7 vec<tree_node*, va_gc, vl_embed>::operator[](unsigned int) /home/vegard/git/gcc/gcc/vec.h:826 0xd70ab7 local_class_index /home/vegard/git/gcc/gcc/cp/mangle.c:1921 0xd8e983 discriminator_for_local_entity /home/vegard/git/gcc/gcc/cp/mangle.c:1957 0xd8e983 write_local_name /home/vegard/git/gcc/gcc/cp/mangle.c:2058 0xd8e983 write_name /home/vegard/git/gcc/gcc/cp/mangle.c:964 0xd91dde write_class_enum_type /home/vegard/git/gcc/gcc/cp/mangle.c:2809 0xd91dde write_type /home/vegard/git/gcc/gcc/cp/mangle.c:2222 0xda3b3b mangle_special_for_type /home/vegard/git/gcc/gcc/cp/mangle.c:3955 0x120dfb7 get_tinfo_decl(tree_node*) /home/vegard/git/gcc/gcc/cp/rtti.c:446 0xcc859b eh_type_info(tree_node*) /home/vegard/git/gcc/gcc/cp/except.c:109 0xcc859b expand_start_catch_block(tree_node*) /home/vegard/git/gcc/gcc/cp/except.c:381 0x1261fb4 finish_handler_parms(tree_node*, tree_node*) /home/vegard/git/gcc/gcc/cp/semantics.c:1338 0x10bb6bf tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/vegard/git/gcc/gcc/cp/pt.c:16448 0x10b8bae tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/vegard/git/gcc/gcc/cp/pt.c:16426 0x10b7d64 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/vegard/git/gcc/gcc/cp/pt.c:16045 0x10ba0da tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/vegard/git/gcc/gcc/cp/pt.c:16322 0x10b7d64 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/vegard/git/gcc/gcc/cp/pt.c:16045 0x10ba0da tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/vegard/git/gcc/gcc/cp/pt.c:16322 0x10b051f instantiate_decl(tree_node*, bool, bool) /home/vegard/git/gcc/gcc/cp/pt.c:23386 0x11eeaf7 instantiate_pending_templates(int) /home/vegard/git/gcc/gcc/cp/pt.c:23502 Version: xgcc (GCC) 8.0.1 20180204 (experimental) built from git fdae6180ad24fa6303fa046114f3e4b66b8db34d Seems to have been introduced since 7.3 because 7.3.0 on godbolt.org says: <source>: In constructor 'a< <template-parameter-1-1> >::a()': <source>:6:23: error: types may not be defined in exception-declarations } catch (struct c {}) { ^ <source>: In instantiation of 'a< <template-parameter-1-1> >::a() [with <template-parameter-1-1> = int]': <source>:16:6: required from here <source>:6:24: error: conflicting declaration 'struct a< <template-parameter-1-1> >::a() [with <template-parameter-1-1> = int]::c' } catch (struct c {}) { ^ <source>:4:12: note: previous declaration as 'struct a< <template-parameter-1-1> >::a() [with <template-parameter-1-1> = int]::c' struct c; ^ <source>:6: confused by earlier errors, bailing out Compiler returned: 1 Test case was reduced by C-Reduce.