title: Received message "Program received signal SIGSEGV: Segmentation fault - invalid memory reference"
body: <p>I'm currenlty learning modern Fortran, I use the TDM-GCC compiler on Windows 10 64bit.
  After compiling correcly my code, I received this message when trying to run the output .exe</p>
  
  <pre><code>Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
  
  Backtrace for this error:
  #0  ffffffffffffffff
  #1  ffffffffffffffff
  #2  ffffffffffffffff
  #3  ffffffffffffffff
  #4  ffffffffffffffff
  #5  ffffffffffffffff
  #6  ffffffffffffffff
  #7  ffffffffffffffff
  #8  ffffffffffffffff
  #9  ffffffffffffffff
  #10  ffffffffffffffff
  #11  ffffffffffffffff
  #12  ffffffffffffffff
  #13  ffffffffffffffff
  #14  ffffffffffffffff
  #15  ffffffffffffffff
  #16  ffffffffffffffff
  #17  ffffffffffffffff
  #18  ffffffffffffffff
  </code></pre>
  
  <p>I understood the problem may be caused by reading I/O files. Here's the code (it's not mine, it's from the course teacher, he told me it's a runtime error, but has no idea why I get the error while reading a file):</p>
  
  <pre><code>program golden_ratio
  ! experiments with the golden ratio iterative relation
    implicit none
    integer, parameter :: rk = kind(1.0d0)
    real(rk) :: phi, phi_old
    real(rk) :: phi_start, tol
    integer :: i, max_iter
  
      open(11,FILE='goldenfile.in',STATUS='old')
      read(11,*) phi_start, tol, max_iter
      close(11)
      ! how I wrote the input file
      ! 5.0
      ! 0.0001
      ! 1000
  
    phi_old = phi_start
    do i=1,max_iter
      phi = 1.0d0/phi_old + 1.0d0
      if (abs(phi - phi_old) &lt; tol) exit
      phi_old = phi
    end do
  
    open(12,FILE='goldenfile.out',STATUS='replace')
    write(12,100) 'Start value:',phi_start
    write(12,100) 'Tolerance:',tol
    write(12,'(2(A," ",I11,"  "))') 'Ended at iteration:', i, 'of', max_iter
    write(12,100) 'Final value:',phi
    close(12)
      print *, 'Output file created'
  
  100 format(A," ",F13.10)
  end program golden_ratio
  </code></pre>
  
  <p>So this problem occurs when I try to open the input file 'goldenfile.in' (which is present in the same directory, defined as I wrote in the commented section, obviously it doesn't contain the comment marks).
  It also occurs when I forgo using the input file, and I try to overwrite the output file 'goldenfile.out' after having obtained it a first time. Using 'replace' or not doesn't change the situation.
  The strange thing is that the compilation goes right.</p>