https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82186
Bug ID: 82186 Summary: internal compiler error with static function Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: criovx at gmail dot com Target Milestone: --- $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc-multilib/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 Thread model: posix gcc version 7.2.0 (GCC) $ cat bug.c unsigned char *trans; unsigned int maxstates; static void evolven(unsigned int *count) { unsigned char newval, oldval = 0; newval = ((unsigned char(*)[maxstates][maxstates])trans)[0][0][0]; if (newval != oldval) { (*count)++; } } void test(unsigned int *count) { evolven(count); } $ gcc -c bug.c $ gcc -O -c bug.c bug.c: In function ‘test’: bug.c:13:2: internal compiler error: Segmentation fault evolven(count); ^~~~~~~~~~~~~~ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. There is no problem if I do not define evolven as static function or do not enable optimization.