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

            Bug ID: 88604
           Summary: Initializing constexpr array consumes all memory
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugs at oxyware dot com
  Target Milestone: ---

Compiling the attached code with g++ 8.2.1 and no optimisation or compiler
flags causes cc1plus to consume all of physical memory until it hits an OOM
Linux error.  Clang compiles this without any problems.  I tried this on
gcc.godbolt.org for various compiler versions and the problem is present in
many previous versions of g++.

The problem doesn't appear if numAirports is set to 500 but it does when at the
full 26^3.  Also, if latArray[i] is assigned a constant rather than copying a
value from the other constexpr class then it works at full size (26^3).  Using
4000, cc1plus peaks at 2.1GB of resident RAM.

# with numAirports == 4000
$ /usr/bin/time g++ index.cpp    
3.27user 1.07system 0:04.38elapsed 99%CPU (0avgtext+0avgdata
2224108maxresident)k
0inputs+144outputs (0major+559502minor)pagefaults 0swaps

$ g++ --version
g++ (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6)

$ uname -a
Linux konan.oxyware.net 4.19.8-200.fc28.x86_64 #1 SMP Mon Dec 10 15:43:40 UTC
2018 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/fedora-release 
Fedora release 28 (Twenty Eight)

Reply via email to