https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100299
Bug ID: 100299
Summary: cc1plus taking all RAM
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent.lextrait at gmail dot com
Target Milestone: ---
Created attachment 50692
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50692&action=edit
ii file to reproduce the issue. gunzip first.
While compiling a relatively large file (ii file ~2 MB), g++ compilation in -O3
aborts after suddenly allocating in a few steps within a few seconds all the
RAM (128 GB!).
Compiles just fine with -O2 (and it takes 5 times longer than to abort in -O3).
To my utter surprise, it compiles with -O2 -fgcse-after-reload -fipa-cp-clone
-floop-interchange -floop-unroll-and-jam -fpeel-loops -fpredictive-commoning
-fsplit-loops -fsplit-paths -ftree-loop-distribution -ftree-loop-vectorize
-ftree-partial-pre -ftree-slp-vectorize -funswitch-loops -fvect-cost-model
-fvect-cost-model=dynamic -fversion-loops-for-strides
While the specific 11.1 man specifies that these options are equivalent to -O3.
Excerpt of man:
-O3 Optimize yet more. -O3 turns on all optimizations specified by -O2 and
also turns on the following optimization flags:
-fgcse-after-reload -fipa-cp-clone -floop-interchange
-floop-unroll-and-jam -fpeel-loops -fpredictive-commoning -fsplit-loops
-fsplit-paths -ftree-loop-distribution -ftree-loop-vectorize
-ftree-partial-pre -ftree-slp-vectorize -funswitch-loops
-fvect-cost-model -fvect-cost-model=dynamic
-fversion-loops-for-strides
The man must not be correct, some other option must be added in -O3.
I am on x86_64-linux-gnu (Ubuntu 20.04) - but I am fairly sure it is not
platform-dependent.
gcc is configured using
./configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --prefix=/usr/local/gcc-11.1
--enable-checking=release --enable-languages=c,c++ --disable-multilib
--program-suffix=-11.1
The complete command line that triggers the bug:
g++-11.1 -std=c++20 -O3 -c test.ii
The error:
g++-11.1: fatal error: Killed signal terminated program cc1plus
compilation terminated.
gzipped test.ii attached to this bug report.
Previous versions of gcc do not exhibit the bug, but do compile very very
slowly compared to -O0 option, or compared to clang.