Author Topic: Program received signal SIGSEGV: Segmentation fault - invalid memory reference  (Read 385 times)

Offline maxlox

  • Single posting newcomer
  • *
  • Posts: 6
Hi, I've write a simple program in fortran as follow:

Code: [Select]
    program file1

    implicit none

    ! Prompt user for a filename and read it:
    CHARACTER*64 filename
    character*64 reading
    WRITE (*, '(A)') ' enter file to create: '
    READ (*, '(A)') filename
    ! Open the file for formatted sequential access as unit 7.
    ! Note that the specified access need not have been specified,
    ! since it is the default (as is "formatted").
    OPEN (7, FILE = filename, ACCESS = 'SEQUENTIAL', STATUS = 'NEW')
    write(7,*)'Nuovo file'

    open(10,file='pippo', access='sequential', status='old')
    read(10,*)reading
    close(7)
    close(10)

    write(*,*) reading

    print *, 'Hello World'

    end program file1

When I run it under Code::Blocks (ver. 17.12, the latest) ide o in command prompt I get an error message as in the image attached. Code::Blocks is installed in a OS windows 10 ( :o ) 64bit.
If I compile and run the same code with "my old computer" (a virtual machine over the same computer), with xp and visual studio intel fortran , all is good!

Can someone help me and show were I fall?

Thanks

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6221
    • My Best Post
Please state the GCC and/or FORTRAN compiler version for both working and non-working versions.
Some GCC Compilers have know FORTRAN bugs!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline maxlox

  • Single posting newcomer
  • *
  • Posts: 6
Please state the GCC and/or FORTRAN compiler version for both working and non-working versions.
Some GCC Compilers have know FORTRAN bugs!

Tim S.

Non working fortran compiler ver is the mingw32-gfortran.exe "GNU Fortran (tdm-1) 5.1.0".
The other, my old fortran compiler, working ver is the "Intel(R) Fortran Compiler 10.1.021 [IA-32]".

It's a compiler's bug?? Can I fix in someway?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6221
    • My Best Post
Please state the GCC and/or FORTRAN compiler version for both working and non-working versions.
Some GCC Compilers have know FORTRAN bugs!

Tim S.

Non working fortran compiler ver is the mingw32-gfortran.exe "GNU Fortran (tdm-1) 5.1.0".
The other, my old fortran compiler, working ver is the "Intel(R) Fortran Compiler 10.1.021 [IA-32]".

It's a compiler's bug?? Can I fix in someway?

IIRC, "GNU Fortran (tdm-1) 5.1.0" is the bad FORTRAN compiler.
I would try an older or newer GCC FORTRAN compiler.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline maxlox

  • Single posting newcomer
  • *
  • Posts: 6
Quote

IIRC, "GNU Fortran (tdm-1) 5.1.0" is the bad FORTRAN compiler.
I would try an older or newer GCC FORTRAN compiler.

Tim S.

I'll try ...  :'( :'(

Thanks Tim S. "stahta01"

Offline BentL

  • Single posting newcomer
  • *
  • Posts: 8
You are doing file operations in Fortran and there is a bug in version 5.1.0 of file "libgfortran-3.dll" causing the error you describe. You need to update  file "libgfortran-3.dll" as described in this post.

Offline maxlox

  • Single posting newcomer
  • *
  • Posts: 6
You are doing file operations in Fortran and there is a bug in version 5.1.0 of file "libgfortran-3.dll" causing the error you describe. You need to update  file "libgfortran-3.dll" as described in this post.

Before I ask for help I've do it (installed the libgfortran-3 described in the post) ... but nothing  :-\

Offline karaul

  • Single posting newcomer
  • *
  • Posts: 4
I used mingw from here https://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version6/
With this replaced compiler, it works now.

(1) download small installer from the above link and install it in c:\mingw
(2) select the fortran package from the fresh installer and install
(3) change in the setting-complier for GNU fortran path to c:\mingw

The logic is clear, and I am sorry, if it the explanation is too short, I am writing this to repeat the procedure on another computer too.