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

            Bug ID: 65518
           Summary: gcc consumes all memory with -O3
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ikonomisma at googlemail dot com

Attempting to compile the following function at -O3 on (at least) gcc 4.8.2
consumes all available memory:

#include <stdint.h>
#include <stddef.h>

typedef struct giga
{
  uint64_t g[0x10000000];
} giga;

uint64_t addfst(giga const *gptr, size_t num)
{
  uint64_t retval = 0;
  for (size_t i = 0; i < num; i++)
    {
      retval += gptr[i].g[0];
    }
  return retval;
}

Reply via email to