https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83230
Bug ID: 83230 Summary: [8.0 regression] segmentation fault in bind C C/C++ Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: juergen.reuter at desy dot de Target Milestone: --- Created attachment 42757 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42757&action=edit Reproducer The following code seg faults in the most recent versions for gcc/g++/gfortran, cf. below. I'm using the gcc trunk 255190 with the patch in https://gcc.gnu.org/viewcvs/gcc/branches/gcc-7-branch/gcc/fortran/resolve.c?r1=255029&r2=255205&pathrev=255205 applied. The C++ code which I adapted here and linked into my Fortran program works standalone with that version of gcc/g++, but the bind(C) fails. I'm not sure whether this an error (or simply a change in the C/C++ API) or whether something in bind(C) broke. The C++ code contains an implementation for an XDR reader, which is applied from a Fortran program via bind(C) to read in the file eio_stdhep_1.hep which is also attached. If this is in bind(C) it could be related https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83225 at least it happened relatively close to the commit causing that bug. $ ./rt_error writing stdhep event ... Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x7fcfa0029caf in ??? #1 0x7fcfa007613c in ??? #2 0x7fcfa1071c05 in _ZN9__gnu_cxx13new_allocatorIcE10deallocateEPcm at /home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:125 #3 0x7fcfa1071c05 in _ZNSt16allocator_traitsISaIcEE10deallocateERS0_Pcm at /home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/alloc_traits.h:462 #4 0x7fcfa1071c05 in _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_destroyEm at /home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:226 #5 0x7fcfa1071c05 in _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv at /home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:221 #6 0x7fcfa1071c05 in _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED4Ev at /home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:647 #7 0x7fcfa1071c05 in _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEED4Ev at /home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/sstream:65 #8 0x7fcfa1071c05 in _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev at /home/reuter/sandbox_gcc8/packages/gcc_trunk/_build/x86_64-pc-linux-gnu/libstdc++-v3/include/sstream:732 #9 0x407b56 in ??? #10 0x406c1d in ??? #11 0x408485 in ??? #12 0x408519 in ??? #13 0x4085f8 in ??? #14 0x40862e in ??? #15 0x7fcfa0014f44 in ??? #16 0x401918 in ??? #17 0xffffffffffffffff in ??? Segmentation fault (core dumped)