https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77562
Bug ID: 77562 Summary: large amount of memory usage when allocating big arrays Product: gcc Version: 6.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: programmerjake at gmail dot com Target Milestone: --- when using gcc 5+, compiling the following code uses a huge amount of memory creating a read-only template object. On gcc 4.9 and before, it does the expected thing, filling the array in a loop without a source object that it's copying from. code: struct S { long a = 1; }; template <typename T, unsigned long N> struct A { T value[N]; }; void *fn() { return new A<A<A<S, 400>, 400>, 400>; }