https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81474

            Bug ID: 81474
           Summary: out of memory on constexpr calculation
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bobk-off at yandex dot ru
  Target Milestone: ---

Code below cause "cc1plus.exe: out of memory allocating 65536 bytes" error on
gcc 6.3.0 for ARM (32bit version). During compilation memory usage grows to
2GB, after it compilation fails. Argument of foo (100000000) had been picked to
demonstrate bug on simple example. With large types (not trivial types) "out of
memory" error occurs on lower for-cycle depth. Look like the compiler use
"allocation from stack" memory model on each cycle iteration and doesn't free
memory after cycle.

constexpr int foo(size_t c)
{
        int a = 0;
        for (int i = 0; i < ci++)
        {
                a += i;
                a -= i;
        }
        return a;
}

constexpr int x = foo(100000000);

Reply via email to