https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82878
Bug ID: 82878 Summary: ICE in assign_temp, at function.c:968 when using optimization Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ksundenkamsc12 at gmail dot com Target Milestone: --- This bug is possibly related to Bug 79989 and/or Bug 82148, but presents itself in a slightly different manner than in either of those examples. The short version: The following command, given the preprocessed source file provided, produces an ICE: ``` $ g++ --verbose -c fd_array.ii -O Using built-in specs. COLLECT_GCC=g++ Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp Thread model: posix gcc version 7.2.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-c' '-O' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/cc1plus -fpreprocessed fd_array.ii -quiet -dumpbase fd_array.ii -mtune=generic -march=x86-64 -auxbase fd_array -O -version -o /tmp/ccOdsz5s.s GNU C++14 (GCC) version 7.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++14 (GCC) version 7.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 5931a2fe3d5a5365a85e56248f3f55d7 sim/fd_array.cc: In member function ‘void FDArray::restoreFileOffsets()’: sim/fd_array.cc:143:5: internal compiler error: in assign_temp, at function.c:968 }; ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. ``` Note, this report is from GCC 7.2.0 running on Arch Linux, but I also observed the same error message using GCC 7.2.1 running on OpenSUSE Tumbleweed. Additional information: This code does compile with no optimization flag or with '-O0', but any other '-O' flag triggers this bug (including '-Ofast' and '-Og'). I was unable to trigger the bug purely by adding optimization flags, even when specifying all flags listed under -O1 at: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html: $ g++ -c fd_array.ii -fauto-inc-dec -fbranch-count-reg -fcombine-stack-adjustments -fcompare-elim -fcprop-registers -fdce -fdefer-pop -fdelayed-branch -fdse -fforward-propagate -fguess-branch-probability -fif-conversion2 -fif-conversion -finline-functions-called-once -fipa-pure-const -fipa-profile -fipa-reference -fmerge-constants -fmove-loop-invariants -freorder-blocks -fshrink-wrap -fshrink-wrap-separate -fsplit-wide-types -fssa-backprop -fssa-phiopt -ftree-bit-ccp -ftree-ccp -ftree-ch -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-phiprop -ftree-sink -ftree-slsr -ftree-sra -ftree-pta -ftree-ter -funit-at-a-time -fomit-frame-pointer This produces one warning on my machine due to the -fdelayed-branch flag which is unsupported by the target machine. In point of fact, I specified all flags from -O1, -O2, and -O3, and had no error. I was able to trigger the ICE using the flags from Bug 79989 ('$ g++ -c fd_array.ii -mmpx -fcheck-pointer-bounds '), but this produced additional output and is not listed as flags which are provided by the '-O' flag (namely, this treated the function as a static member function rather than simply a "member function"): sim/fd_array.cc: In static member function ‘static void FDArray::restoreFileOffsets()::<lambda(std::shared_ptr<FileFDEntry>)>::_FUN.chkp(std::shared_ptr<FileFDEntry>, \xe2\x80\x98pointer_bounds_typ\xe2\x80\x99 not supported by dump_type#<type error>, void, ...)’: sim/fd_array.cc:143:5: internal compiler error: in assign_temp, at function.c:968 }; ^ The original code compiles with g++-6 (though the g++-7 preprocessed file provided here does not complete compilation with g++-6) The source file is from the gem5 cpu simulator, BSD 3-clause licensed