https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95705
Bug ID: 95705 Summary: Internal compiler error generated when using int cast as array index Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: staffordstyle at gmail dot com Target Milestone: --- main.ii =================================== # 1 "main.cpp" # 1 "<built-in>" # 1 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 1 "<command-line>" 2 # 1 "main.cpp" struct IntLike { operator int() const { return 0; } }; template<typename T> void useAsArrayIndex( const IntLike a ) { float myArray[1]; myArray[ a ]; } int main() { } Compile command: =================================== g++ -save-temps main.cpp main.cpp: In function ‘void useAsArrayIndex(IntLike)’: main.cpp:13:14: internal compiler error: unexpected expression ‘(int)a’ of kind implicit_conv_expr 13 | myArray[ a ]; | ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. Compiler version: =================================== g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/me/toolchain/install/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /home/me/toolchain/source/gcc/./configure --prefix=/home/me/toolchain/install --disable-multilib --disable-bootstrap --enable-shared --enable-languages=c,c++,fortran --with-mpc=/home/me/toolchain/install --with-mpfr=/home/me/toolchain/install --with-gmp=/home/me/toolchain/install --with-isl=/home/me/toolchain/install Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.1.0 (GCC) I also tested on godbolt with these versions of GCC: 9.3 no error 10.1 same error as above 11 same error as above Also, thank you for GCC.