The following code does not compile with Intel Fortran v16, v17, on x86-64 Linux:
module mymod implicit none type :: mytype private integer :: a contains procedure,private :: eq generic :: operator(==) => eq endtype mytype interface mytype module procedure :: constructor endinterface mytype contains type(mytype) function constructor(a) integer,intent(in),optional :: a if(present(a))then constructor % a = a else constructor % a = 0 endif endfunction constructor logical function eq(m0,m1) class(mytype),intent(in) :: m0 class(mytype),intent(in) :: m1 eq = m0 % a == m1 % a endfunction eq endmodule mymod module wrapper_module use mymod,only:mytype endmodule wrapper_module program test use wrapper_module implicit none write(*,*)mytype() == mytype(0) endprogram test
The compiler does not seem to resolve the overloaded == operator for mytype:
$ ifort test.f90 test.f90(44): error #6355: This binary operation is invalid for this data type. write(*,*)mytype() == mytype(0) ----------^ test.f90(44): error #6355: This binary operation is invalid for this data type. write(*,*)mytype() == mytype(0) ----------------------^ compilation aborted for test.f90 (code 1)
If the main program accesses mytype directly from mymod, the program compiles and executes as expected.
If the main program accesses mytype from wrapper_module, and wrapper module accesses mytype via "use mymod", the program compiles and executes as expected.
If the main program accesses mytype from wrapper_module, and wrapper module accesses mytype via "use mymod,only:mytype" (the example code above), the compilation fails with the above message. I think this is unexpected behavior.
The code compiles and executes as expected when compiled with gfortran 5.x
Thanks,
milan
Zone:
Thread Topic:
Bug Report