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

2014-11-03 Thread gcc-bugzilla at bmevers dot de
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 
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)


[Bug c++/63904] New: ICE when acessing array member of constexpr struct

2014-11-16 Thread gcc-bugzilla at bmevers dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63904

Bug ID: 63904
   Summary: ICE when acessing array member of constexpr struct
   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

Created attachment 33994
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33994&action=edit
Preprocessed source

The following code causes an internal compiler error:


template
struct foo {
constexpr foo() : a() {}
int a[N];
};

int main() {
foo< (foo<1>{}).a[0] > f;
}


constexpr-initalization.cpp:7:25:   in constexpr expansion of
‘f.foo::foo<0>()’
constexpr-initalization.cpp:7:25: internal compiler error: in tree_low_cst, at
tree.h:4849
 foo< (foo<1>{}).a[0] > f;