https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85583
--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> --- Reduced test-case: $ cat json.ii class b { public: virtual ~b(); }; template <typename> class c : b {}; class B { c<char> d; }; extern template class c<char>; main() { B a; } $ ./xgcc -B. -flto=8 -O2 -std=gnu++17 json.ii json.ii:10:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] main() { B a; } ^ lto1: internal compiler error: in lto_balanced_map, at lto/lto-partition.c:836 0x62014f lto_balanced_map(int, int) ../../gcc/lto/lto-partition.c:836 0x614b2c do_whole_program_analysis ../../gcc/lto/lto.c:3179 0x614b2c lto_main() ../../gcc/lto/lto.c:3374 Honza, can you please fix that?