https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87099
Bug ID: 87099 Summary: internal compiler error: segmentation fault Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: moron at waifu dot club Target Milestone: --- Created attachment 44593 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44593&action=edit the preprocessed file from -save-temps Code to reproduce: #include <stdio.h> #include <string.h> int main(int argc, char const *argv[]){ char myArray[argc]; int a = strncmp(&(myArray[1]),"aaaa",3); return 0; } Compiler command to reproduce: gcc test.c Note: This does not happen if the size of myArray is just a constant number. If the strlen of the second argument to strncmp is less than the third argument, the bug does not happen. If you remove the "int a = " part and just do nothing with the return value of strncmp then the bug does not happen. I was able to compile this code last month, probably using GCC 8.1. Output with verbose: gcc -save-temps --verbose test4.c Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper 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 --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto Thread model: posix gcc version 8.2.0 (GCC) COLLECT_GCC_OPTIONS='-save-temps' '-v' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -E -quiet -v test4.c -mtune=generic -march=x86-64 -fpch-preprocess -o test4.i ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include /usr/local/include /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-save-temps' '-v' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -fpreprocessed test4.i -quiet -dumpbase test4.c -mtune=generic -march=x86-64 -auxbase test4 -version -o test4.s GNU C17 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C17 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 374c644ab4db4fa02e30fa5669d43e86 during RTL pass: expand test4.c: In function ‘main’: test4.c:6:10: internal compiler error: Segmentation fault int a = strncmp(&(myArray[1]),"aaaa",3); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions.