https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96197
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2020-07-15 Known to fail| |10.1.0, 11.0 Keywords| |memory-hog --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Does it help if you replace your simplistic O(n) algorithms with O(log n) ones? That is, constexpr const struct word_type &WORD_LOOKUP(WORD index, const struct word_type *table_row =word_table) { for (;;) { if (table_row->index == index) return *table_row; if (table_row->index == WORD::NONE) return word_lookup(WORD::NONE); ++table_row; } // return table_row->index == index ? *table_row : (table_row->index == WORD::NONE ? word_lookup(WORD::NONE) : WORD_LOOKUP(index, ++table_row)); } replace the for (;;) loop with table_row[index] (OK, that's maybe too much guessing into your data structure) or with a binary search over the table which you keep sorted? It's probably simply garbage that accumulates during constexpr evaluation. -ftime-report shows constant expression evaluation : 28.45 ( 92%) 1.57 ( 96%) 32.97 ( 92%) 5127882 kB (100%) that is 5GB of GC memory from constexpr evaluation.