Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Error 6633 for type-bound operators when derived type is second argument

Christopher_M_
Beginner
373 Views

I've come across a bug which I think is similar to https://software.intel.com/pt-br/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/583935. When create an abstract type with type-bound operators, ifort 15.03 complains when I try to use the operator with the derived type as teh second argument. I've attached a minimal example (slightly less minimal than it could be in order to demonstrate various similar cases which do work).

module rhs_arg
  implicit none
  
  type, abstract :: test
  contains
    procedure(r_t), deferred, pass(rhs) :: subtract_rhs
    procedure(t_r), deferred :: subtract_lhs
    procedure(t_t), deferred :: subtract
    procedure :: negate
    procedure(eq), deferred :: assign
    generic :: operator(-) => subtract, subtract_lhs, subtract_rhs, negate
    generic :: assignment(=) => assign
  end type test

  abstract interface
     pure function r_t(lhs,rhs)
       import :: test
       real, intent(in) :: lhs
       class(test), intent(in) :: rhs
       class(test), allocatable :: r_t
     end function r_t
     
     pure function t_r(this,rhs)
       import :: test
       class(test), intent(in) :: this
       real, intent(in) :: rhs
       class(test), allocatable :: t_r
     end function t_r
     
     pure function t_t(this,rhs)
       import :: test
       class(test), intent(in) :: this, rhs
       class(test), allocatable :: t_t
     end function t_t

     pure subroutine eq(lhs,rhs)
       import :: test
       class(test), intent(inout) :: lhs
       class(test), intent(in)    :: rhs
     end subroutine eq
  end interface

contains
  
  function negate(this)
    class(test), intent(in) :: this
    class(test), allocatable :: negate
    allocate(negate, mold=this)
    negate = 0.0 - this
    ! Examples of things which do compile
    negate = this%subtract_rhs(0.0)
    negate = this - 0.0
    negate = this - this
  end function negate

end module rhs_arg

This produces the error message:

rhs_arg.f90(49): error #6633: The type of the actual argument differs from the type of the dummy argument.   [THIS]
    negate = 0.0 - this
-------------------^
compilation aborted for rhs_arg.f90 (code 1)

 

0 Kudos
10 Replies
FortranFan
Honored Contributor II
373 Views

Christoper MacMackin wrote:

.. ifort 15.03 complains when I try to use the operator with the derived type as teh second argument..

Latest Intel Fortran compiler, version 17 update 1 compiles the code Ok without any error complaint.

0 Kudos
Christopher_M_
Beginner
373 Views

Unfortunately, 15.03 is the latest version available on the system I'm running on. Good to know it's been fixed, though.

0 Kudos
FortranFan
Honored Contributor II
373 Views

Christopher MacMackin wrote:

Unfortunately, 15.03 is the latest version available on the system I'm running on. Good to know it's been fixed, though.

For several of the features from Fortran 2003 and newer standard revisions, I find one has to remain quite current on compiler version updates but I fully understand and empathize with situations when this may not be possible.

0 Kudos
Kevin_D_Intel
Employee
373 Views

I'm not certain that all is well with PSXE 2017 Update 1 either. Your case compiles with PSXE 2017 (initial and update 1). It also compiles with 16.0 (all releases).

For the earlier report you cited, the reduced test case Steve provided development also now compiles with 16.0 and 17.0 compilers; however, the OP's larger test case compiles but fails to link. It suffers an undefined reference to type_abstract_buggy_mp_buggy_assign_buggy_.

The internal tracking id for the earlier cited post is also not yet closed. It discusses addressing the internal compiler error only at this time. There were a few different issues (internal errors, compilation errors #6633, etc.) at play in the earlier post and test case. It seems work in the affected area of the compiler has perhaps addressed some aspects but not all at this time. It could be true for your full case that while the compilation succeeds with a newer compiler, it too may not successfully link.

It would be great if you could get a newer release on your system to at least test with and know where your code stands.

0 Kudos
Christopher_M_
Beginner
373 Views

FortranFan wrote:

For several of the features from Fortran 2003 and newer standard revisions, I find one has to remain quite current on compiler version updates but I fully understand and empathize with situations when this may not be possible.

I'm surprised by this one, though, since gfortran supports it without any problem (it just fails to deallocate the polymorphic function results, which makes the library unusable for a different reason). I'll see if I can get a newer version installed under a student or open source license.

0 Kudos
Christopher_M_
Beginner
373 Views

I managed to get the latest versino of ifort installed. The bug listed here is not showing up, but another bug surfaced instead. I don't have time to prepare a report tonight, so I'll open another thread on it tomorrow. Given that, I obviously haven't been able to see if everything works at link-time.

0 Kudos
Kevin_D_Intel
Employee
373 Views

Ok, sorry to hear there's possible other issues. We'll watch for further info from you.

0 Kudos
Christopher_M_
Beginner
373 Views

I've opened another thread demonstrating the new bug I've encountered in ifort: https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/709663

0 Kudos
Christopher_M_
Beginner
373 Views

I found a temporary workaround for the bug I reported in the other (linked) thread and was able to produce a the static library for my software. However, when I tried to compile the test-suite, the same error arose in a manner not congenial for a workaround. I also encountered an ICE, seemingly in a similar situation (a type-bound binary operator). I commented out the offending lines just to see whether it could link. However, as you said, it failed to link because it couldn't find the procedure used for defined assignment.

 

0 Kudos
Kevin_D_Intel
Employee
373 Views

I'm very sorry to hear about the additional errors. I know it is asking more of your time, but at your convenience, if you can provide a reproducer for the ICE then I will escalate that to our Developers. I will also inform that you appear now to be blocked by the failed link.

0 Kudos
Reply