https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87437
Bug ID: 87437 Summary: g++ ICE Segfault initializing implicitly sized array in template with enum index Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: james at albanarts dot com Target Milestone: --- Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu Build: x86_64-pc-linux-gnu Created attachment 44751 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44751&action=edit segfault.cpp - Really simple test case I hit an internal compiler error in g++. Reduced test case attached and pasted here: enum E { ENUM }; template <typename T> void foo() { int arr[] = { [ENUM] = 0 }; } Compiled like this on Gentoo (sys-devel/gcc-7.3.0-r3): $ g++ -c -o segfault.o segfault.cpp segfault.cpp: In function ‘void foo()’: segfault.cpp:6:27: internal compiler error: Segmentation fault int arr[] = { [ENUM] = 0 }; ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.gentoo.org/> for instructions. It works if the template line is removed. It works if ENUM is replaced with integer literal (i.e. "[0] = 0"). It works if an explicit size is given (i.e. "int arr[1]"). I'm not able to test on a newer version right now, but its a trivial test case, maybe somebody else can check if its already fixed? $ g++ -v Using built-in specs. COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/7.3.0/g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-7.3.0-r3/work/gcc-7.3.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/7.3.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/7.3.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/7.3.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/7.3.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/7.3.0/python --enable-languages=c,c++,fortran --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 7.3.0-r3 p1.4' --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-libcilkrts --disable-libmpx --enable-vtable-verify --enable-libvtv --enable-lto --without-isl --enable-libsanitizer --enable-default-pie --enable-default-ssp Thread model: posix gcc version 7.3.0 (Gentoo 7.3.0-r3 p1.4)