[Bug c++/63728] New: Memory exhaustion using constexpr constructors for classes with large array members

gcc-bugzilla at bmevers dot de gcc-bugzilla@gcc.gnu.org
Tue Nov 4 01:29:00 GMT 2014


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

            Bug ID: 63728
           Summary: Memory exhaustion using constexpr constructors for
                    classes with large array members
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugzilla at bmevers dot de

Having a constexpr constructor on a class with a large array member will result
in excessive memory usage. For example, I wasn't able to compile the following
program using -std=c++11 on a machine with 4GiB of RAM:

#include <bitset>
int main() {
    std::bitset<2147483648> bs; 
}

This happens because the constructor of bitset is constexpr, so it will try to
initialize the large member array at compile time, which will create at least
one ast tree node for every element in the array. (gcc/cp/constexpr.c:1874)



More information about the Gcc-bugs mailing list