A bug(maybe) in MinGW+gfortran

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

A bug(maybe) in MinGW+gfortran

gcc - fortran mailing list
Dear all,


I made a test program that raises an error on the MinGW+gfortran+win10, while it's ok on Ubuntu+gfortran. The 2 source code files are below.


module_test.F
      module module_test
      implicit none
      type:: complex_os
      real :: re  
      real :: im  
      end type complex_os
      contains
      type(complex_os) function sum_c(a,b)
C    computing the sum of two complexes.
      type(complex_os),intent(in)::a,b
      sum_c%re=a%re+b%re
      sum_c%im=a%im+b%im
      end function sum_c
      end module module_test


fu.F
      real function fu(a)
      use module_test
      implicit none
      type(complex_os),intent(in)::a
      fu = sqrt(a%re*a%re+a%im*a%im)
      end function fu


On the Win10+MinGW+gfortran 5.4.0
1.Compile module_test.F ,OK.
gfortran -Wall -g -c module_test.f
2.Compile fu.F,raises an error.
$ gfortran -Wall -g -c fu.f
f951.exe: Fatal Error: Reading module 'module_test' at line 21 column 61: Unexpected EOF
compilation terminated.


Someone may be interesting that problem and solve it.


Best,
Tian




fu.f (228 bytes) Download Attachment
module_test.f (512 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: A bug(maybe) in MinGW+gfortran

gcc - fortran mailing list
Hi Tian

The only mingw that I have access to is that supplied with octave.

>> system('uname -s')
MINGW32_NT-6.2
ans = 0
>> system('gfortran --version')
GNU Fortran (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ans = 0
>> system('gfortran ./tian1.F -g -c -Wall')
ans = 0
>> system('gfortran ./tian2.F -g -c -Wall')
ans = 0
>> system('gfortran ./tian1.o ./tian2.o ./tian.f90 -g -Wall')
ans = 0
>> system('a.exe')
   3.00000000       3.00000000
   1.00000000
ans = 0
>> system('cat tian.f90')
  use module_test
  implicit none
  interface
    real function fu(a)
      import
      type(complex_os), intent(in) :: a
    end function
  end interface
  print *, sum_c (complex_os(1.0,1.0), complex_os(2.0,2.0))
  print *, fu (sum_c (complex_os(1.0,1.0), complex_os(2.0,2.0))) /
sqrt(18.0)
end
ans = 0

Sorry, I cannot reproduce your problem.

I suggest that you update your mingw using:
>> mingw-get update
followed by
>> mingw-get upgrade

Cheers

Paul


On Fri, 3 Apr 2020 at 10:35, wxtian via Fortran <[hidden email]> wrote:

> Dear all,
>
>
> I made a test program that raises an error on the MinGW+gfortran+win10,
> while it's ok on Ubuntu+gfortran. The 2 source code files are below.
>
>
> module_test.F
>       module module_test
>       implicit none
>       type:: complex_os
>       real :: re
>       real :: im
>       end type complex_os
>       contains
>       type(complex_os) function sum_c(a,b)
> C    computing the sum of two complexes.
>       type(complex_os),intent(in)::a,b
>       sum_c%re=a%re+b%re
>       sum_c%im=a%im+b%im
>       end function sum_c
>       end module module_test
>
>
> fu.F
>       real function fu(a)
>       use module_test
>       implicit none
>       type(complex_os),intent(in)::a
>       fu = sqrt(a%re*a%re+a%im*a%im)
>       end function fu
>
>
> On the Win10+MinGW+gfortran 5.4.0
> 1.Compile module_test.F ,OK.
> gfortran -Wall -g -c module_test.f
> 2.Compile fu.F,raises an error.
> $ gfortran -Wall -g -c fu.f
> f951.exe: Fatal Error: Reading module 'module_test' at line 21 column 61:
> Unexpected EOF
> compilation terminated.
>
>
> Someone may be interesting that problem and solve it.
>
>
> Best,
> Tian
>
>
>
>

--
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein