https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106260
--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> --- IPA-CP is confused by seeing a local function which does not have any caller, it expects that all such functions would be removed as unreachable. The assert has been somewhat useful so I'd rather keep it but perhaps it should not trigger when there is -fno-toplevel-reorder in place? Of course, using both -fno-toplevel-reorder and -fwhole-program is a bit strange . Interestingly, the manual description of -fno-toplevel-reorder only says that "unreferenced static variables are not removed" but does not say anything about not removing static uncalled functions.