On Thu, 9 Jul 2020 at 21:34, Mandeep Sandhu via Gcc-help <gcc-help@xxxxxxxxxxx> wrote: > > Hi All, > > I have an strange (to me) issue, where trying to compile a header > which has a single "std::unordered_set<std::string>" initialized with > around 50K short strings is taking forever. > > The set is declared as: > const std::unordered_set<std::string> my_set ({"item1", "item2", ....}); This constructs an enormous array of std::string. If construction of any element of the array throws, then all previous elements need to be destroyed. There are known performance problems with the way G++ handles cases like this, because the exception handling creates a huge amount of overhead. You can find several bugs in bugzilla related to the construction of large arrays of non-trivial types.