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

            Bug ID: 79225
           Summary: Memory hog for large initializers
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: memory-hog
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

With

#include <bitset>

const auto SIEVE_SIZE = 1UL<<32;

int main() {
    std::bitset<SIEVE_SIZE> set;
    return 0;
}

the C++ FE builds a large zero-initializer:

;; Function int main() (null)
;; enabled by -tree-original


{
  struct bitset set = {.D.24903={._M_w={0, 0, 0, 0, 0, 0, 0,.... 0, 0}}};
  <<cleanup_point   struct bitset set = {.D.24903={._M_w={0, 0, 0,...0,
0}}};>>;
  return <retval> = 0;
}
return <retval> = 0;

which while nicely optimized at gimplification time to

int main() ()
{
  int D.27535;

  {
    struct bitset set;

    try
      {
        set = {};
        D.27535 = 0;
        return D.27535;
      }
    finally
      {
        set = {CLOBBER};
      }
  }
  D.27535 = 0;
  return D.27535;
}

hogs >4GB of memory (don't try to enlarge the bitset...).

Reply via email to