https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84619
Bug ID: 84619 Summary: Segmentation fault when running a c-program which is calling a fortran subroutine Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: mario-baumann at web dot de Target Milestone: --- Created attachment 43531 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43531&action=edit contains the 4 sources: lnx_c.c, lnx_f.f, mac_c.c and mac_f.f I have a strange segmentation fault when running the c-programm which is calling a fortran subroutine. The strip down created slightly different codes on linux and macOS. GCC revision: 258059 Tested on: (1) linux > /Gcc/8.0.1/bin/gcc -v Using built-in specs. COLLECT_GCC=/Gcc/8.0.1/bin/gcc COLLECT_LTO_WRAPPER=/opt/Gcc/8.0.1/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /Gcc/8.0.1/.src/configure --prefix=/Gcc/8.0.1 --enable-languages=c,c++,fortran --enable-lto --disable-nls --disable-libquadmath --disable-libquadmath-support Thread model: posix gcc version 8.0.1 20180228 (experimental) (GCC) > /Gcc/8.0.1/bin/gcc -c -m64 -march=nocona -O1 lnx_c.c > /Gcc/8.0.1/bin/gfortran -o z_lnx -m64 -march=nocona lnx_c.o lnx_f.f > ./z_lnx Segmentation fault (core dumped) (2) macOS > /Gcc/8.0.1/bin/gcc -v Using built-in specs. COLLECT_GCC=/Gcc/8.0.1/bin/gcc COLLECT_LTO_WRAPPER=/Gcc/8.0.1/libexec/gcc/x86_64-apple-darwin17/8.0.1/lto-wrapper Target: x86_64-apple-darwin17 Configured with: /Gcc/8.0.1/.src/configure --prefix=/Gcc/8.0.1 --build=x86_64-apple-darwin17 --enable-languages=c,c++,fortran --enable-lto --enable-stage1-checking --enable-libstdcxx-time --disable-nls --disable-libquadmath --disable-libquadmath-support --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-as=/opt/local/bin/as --with-system-zlib --with-pkgversion=svn-revision-258059 Thread model: posix gcc version 8.0.1 20180228 (experimental) (svn-revision-258059) > /Gcc/8.0.1/bin/gcc -c -m64 -march=nocona -O1 mac_c.c > /Gcc/8.0.1/bin/gfortran -o z_mac -m64 -march=nocona mac_c.o mac_f.f > ./z_mac Segmentation fault: 11 Findings: (1) -O2 instead of -O1 crashes too (2) -O0 works fiine (3) gcc-7.3 works fine with -O0, -O1 and -O2 (4) valgrind complains about: ==11458== at 0x501846A: _gfortran_string_index (string_intrinsics_inc.c:254) ==11458== at 0x5018483: _gfortran_string_index (string_intrinsics_inc.c:270)