https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422
Bug ID: 86422 Summary: G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: boris.staletic at gmail dot com Target Milestone: --- My gcc version is 8.1.0. I have not tried with the latest gcc snapshot. If requested, I will compile a gcc snapshot and try to reproduce. My CHOST triple is x86_64-pc-linux-gnu, but I've also managed to get g++ to ICE with an arm-linux-gnueabihf-g++, version 7.3.0, CHOST arm-linux-gnueabihf. My gcc has been configured with: /var/tmp/portage/sys-devel/gcc-8.1.0-r3/work/gcc-8.1.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/8.1.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.1.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.1.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.1.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.0/include/g++-v8 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/8.1.0/python --enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 8.1.0-r3 p1.3' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libmpx --disable-systemtap --enable-vtable-verify --enable-libvtv --disable-libquadmath --enable-lto --without-isl --enable-libsanitizer --enable-default-pie --enable-default-ssp The preprocessed file, while being "just" a static array within a trivial function, it's almost 6MB, so instead of attaching the file I have to post the link: https://raw.githubusercontent.com/bstaletic/gcc_ice/master/gcc/CodePoint.ii When compiled with "g++ -S CodePoint.ii -o CodePoint.s", produces an empty "CodePoint.s" and the following error: g++: internal compiler error: Segmentation fault signal terminated program cc1plus Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.gentoo.org/> for instructions. - Simple changes that avoid ICE: - Adding "-flto". - Changing the "std::string"s in the "RawCodePoint" (lines 19480 to 19483) struct to a "char*". - Makes the compile time really short, produces the assembly. - Changing the "std::string"s in the "RawCodePoint" struct to a "char[]". - Somewhat shorter compile time, produces the assembly. - Moving the static array into global scope. - Changes that caused other strange behaviour, without compiling: - Shortening the array by 30.000 elements (from the original >132.000) caused gcc to exhaust all ram (8GB), take half of the swap (4GB), end up not using the CPU (only ram, went over the 12GB) and after a long while I hit ctrl-c. Note: Compiling takes more than 8GB of ram.