Search code examples
fortrangfortran

Why does this 3-line gfortran code throw a segmentation fault?


This simple 3-line gfortran code generates a "Program received signal SIGSEGV: Segmentation fault - invalid memory reference" at the OPEN statement. What am I doing wrong?

I've turned off (and back on) the "Run-time checks" compiler switches: -fcheck= all and -fcheck=bounds. No improvement from doing this. Other compile switches are off. I also tried defining the name of the file in the OPEN statement in a character variable. Also, no improvement. Also tried replacing single quotes with double quotes. No help.

  PROGRAM INTSFRACM_271
  OPEN(7,IOSTAT=IOS,FILE='namlist.int',STATUS='OLD')
  END

This is the entire program.

See above.


Solution

  • So, very unfortunately, GFortran v5.1.0 is bugged such that valid files will cause a segfault when OPENed. Try updating to v5.2 or higher.