https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93951
Bug ID: 93951 Summary: ICE with '-flto -femit-struct-debug-baseonly' Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: guillaume at morinfr dot org Target Milestone: --- Created attachment 47917 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47917&action=edit reproducer This program ICEs with '-g -flto -femit-struct-debug-baseonly -std=gnu++2a' with gcc 9.2 and 8.3 (seems to work on the trunk). Remove any of -g, -flto, -femit-struct-debug-only and it builds fine. #include <variant> struct S1 { bool fct() const; }; struct S2 { bool fct() const; }; struct V { bool visit() const { auto visitor = [](auto&& s) -> bool { return s.fct(); }; return std::visit(visitor, v); } using Variant = std::variant<S1, S2>; Variant v; }; #0 htab_hash_string (p=0x0) at ../../src/libiberty/hashtab.c:838 #1 0x000000000085acad in external_ref_hasher::hash (r=<synthetic pointer>) at ../../src/gcc/dwarf2out.c:8917 #2 hash_table<external_ref_hasher, false, xcallocator>::find_slot (insert=INSERT, value=<optimized out>, this=0x206fa40) at ../../src/gcc/hash-table.h:423 #3 lookup_external_ref (map=map@entry=0x206fa40, die=0x7ffff58f93c0) at ../../src/gcc/dwarf2out.c:8945 #4 0x000000000085ad6f in optimize_external_refs_1 (die=0x7ffff58f9370, map=0x206fa40) at ../../src/gcc/dwarf2out.c:8983 #5 0x000000000085ad40 in optimize_external_refs_1 (die=0x7ffff58f9320, map=0x206fa40) at ../../src/gcc/dwarf2out.c:8987 #6 0x000000000085ad40 in optimize_external_refs_1 (die=0x7ffff58f92d0, map=0x206fa40) at ../../src/gcc/dwarf2out.c:8987 #7 0x000000000085ae59 in optimize_external_refs (die=die@entry=0x7ffff58f92d0) at ../../src/gcc/dwarf2out.c:9036 #8 0x0000000000860ac8 in output_comp_unit (die=0x7ffff58f92d0, output_if_empty=<optimized out>, dwo_id=0x0) at ../../src/gcc/dwarf2out.c:11055 #9 0x000000000088caa4 in dwarf2out_early_finish (filename=0x7fffffffd76d "g++9_lto_crash.cc") at ../../src/gcc/dwarf2out.c:32264 #10 0x0000000000801025 in symbol_table::finalize_compilation_unit (this=0x7ffff665f100) at ../../src/gcc/cgraphunit.c:2860 #11 0x0000000000b69cbd in compile_file () at ../../src/gcc/toplev.c:481