Bug 79225 - Memory hog for large initializers
Summary: Memory hog for large initializers
Status: RESOLVED DUPLICATE of bug 56671
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: memory-hog
Depends on:
Blocks:
 
Reported: 2017-01-25 10:22 UTC by Richard Biener
Modified: 2017-01-25 10:23 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2017-01-25 10:22:44 UTC
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...).
Comment 1 Richard Biener 2017-01-25 10:23:25 UTC
dup

*** This bug has been marked as a duplicate of bug 56671 ***