https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121935
Bug ID: 121935 Summary: [16 Regression] various LTO streamer ICEs since g:b9fde0219f35cd5244f647c20c7b31b0395dbc5a Product: gcc Version: 16.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: tnfchris at gcc dot gnu.org CC: nshead at gcc dot gnu.org Target Milestone: --- Target: aarch64* Since g:b9fde0219f35cd5244f647c20c7b31b0395dbc5a >From b9fde0219f35cd5244f647c20c7b31b0395dbc5a Mon Sep 17 00:00:00 2001 From: Nathaniel Shead <nathanielosh...@gmail.com> Date: Wed, 10 Sep 2025 14:25:22 +1000 Subject: [PATCH] ipa-free-lang-data: Don't walk into DECL_CHAIN when finding decls/types [PR121865] On a DECL, TREE_CHAIN will find any other declarations in the same binding level. This caused an ICE in PR121865 because the next entity in the binding level was the uninstantiated unique friend 'foo', for which after being found the compiler tries to generate a mangled name for it and crashes. The following testcase -- foo.ii struct a { static int b; }; template <int> struct c { struct d { d e(unsigned, unsigned, bool, bool, bool, unsigned, a); }; }; template <> c<2>::d c<2>::d::e(unsigned, unsigned, bool, bool, bool, unsigned, const a) { } compiled with g++ -S -o /dev/null -flto=auto -std=c++11 ICEs with during IPA pass: modref quadrature.ii: At top level: quadrature.ii:10:79: internal compiler error: in streamer_write_chain, at tree-streamer-out.cc:555 0x1f6f273 internal_error(char const*, ...) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/diagnostic-global-context.cc:786 0x8752b7 fancy_abort(char const*, int, char const*) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/diagnostics/context.cc:1786 0x12dc01b streamer_write_chain /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-streamer-out.cc:555 0x12dc01b streamer_write_chain /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-streamer-out.cc:547 0x12de88b write_ts_type_non_common_tree_pointers /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-streamer-out.cc:763 0x12de88b streamer_write_tree_body(output_block*, tree_node*) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-streamer-out.cc:970 0xf0aeb7 lto_write_tree_1 /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/lto-streamer-out.cc:516 0xf11b6f DFS::DFS(output_block*, tree_node*, bool, bool, bool) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/lto-streamer-out.cc:922 0xf12b0b lto_output_tree(output_block*, tree_node*, bool, bool) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/lto-streamer-out.cc:1886 0xf0b09f write_global_stream /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/lto-streamer-out.cc:2968 0xf15a1f lto_output_decl_state_streams(output_block*, lto_out_decl_state*) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/lto-streamer-out.cc:3015 0xf15a1f produce_asm_for_decls() /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/lto-streamer-out.cc:3427 0xf94a2f write_lto /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/passes.cc:2784 0xf94a2f ipa_write_summaries_1 /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/passes.cc:2847 0xf94a2f ipa_write_summaries() /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/passes.cc:2902 0xbec817 ipa_passes /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/cgraphunit.cc:2276 0xbec817 symbol_table::compile() /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/cgraphunit.cc:2351 0xbee843 symbol_table::compile() /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/cgraphunit.cc:2329 0xbee843 symbol_table::finalize_compilation_unit() /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/cgraphunit.cc:2608