https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82593
Bug ID: 82593 Summary: Internal compiler error: in process_init_constructor_array, at cp/typeck2.c:1294 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ao2 at ao2 dot it Target Milestone: --- Created attachment 42386 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42386&action=edit Parenthesized struct array memeber initializer with enum as indices Hi, I get an "internal compiler error" with the attached code. The problem shows up with both g++-6 and g++-7 from Debian unstable: ----------------------------------------------------------------------- $ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 7.2.0-10' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.2.1 20171014 (Debian 7.2.0-10) ----------------------------------------------------------------------- ----------------------------------------------------------------------- $ g++-6 -v Using built-in specs. COLLECT_GCC=g++-6 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 6.4.0-8' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 6.4.0 20171010 (Debian 6.4.0-8) ----------------------------------------------------------------------- Compiling with no extra options gives the ICE: ----------------------------------------------------------------------- $ g++ -c parenthesized_struct_array_initializer_with_enum_indices.cpp parenthesized_struct_array_initializer_with_enum_indices.cpp: In constructor ‘SomeClass::SomeClass()’: parenthesized_struct_array_initializer_with_enum_indices.cpp:17:3: internal compiler error: in process_init_constructor_array, at cp/typeck2.c:1294 }) ^ Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions. ----------------------------------------------------------------------- AFAICS the bug is triggered when using *enum* values as indices AND the array member initializer uses parentheses. The use of parentheses seems to be a GNU extension, as clang++ also points out: ----------------------------------------------------------------------- $ clang++-4.0 -std=c++11 -c parenthesized_struct_array_initializer_with_enum_indices.cpp parenthesized_struct_array_initializer_with_enum_indices.cpp:14:4: error: parenthesized initialization of a member array is a GNU extension [-Wgnu-array-member-paren-init] : member({ ^ ~ 1 error generated. ----------------------------------------------------------------------- The ICE goes away either removing the parentheses around the initializer (hence adhering to the C++11 standard) or using numbers as indices. I am not sure if this is related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81837 Thanks, Antonio