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

Two strange Warnings(6706;6738) with abstract interfaces

Wolf_W_
New Contributor I
1,105 Views

Hello, i get those two warning messages, when compiling the code below.

"(22) warning #6706: There is a mixture of specific functions and specific subroutines for one generic-spec.   [INTF_SETARRAY]"
"(28) warning #6738: The type/rank/keyword signature for this specific procedure matches another specific procedure that shares the same generic-name.   [INTF_GETSCALAR]"

I do not understand, what is wrong with those declarations. This contruct seems to work fine in my real code, but the warnings confused me.

Greetings
Wolf

Compiler: 15.5 and 16.1

module FOO
  implicit none

!=================================================================
  type, abstract :: ABSTRACT_TYPE
  contains

    procedure(intf_getArray),  deferred :: getArray
    procedure(intf_setArray),  deferred :: setArray
    procedure(intf_getScalar), deferred :: getScalar
    procedure(intf_setScalar), deferred :: setScalar

  end type ABSTRACT_TYPE

!=================================================================
  interface abstract
    real pure function intf_getArray(this) result(res)
      import :: ABSTRACT_TYPE
      class(ABSTRACT_TYPE), intent(in   ) :: this
    end function

    pure subroutine intf_setArray(this, inp)
      import :: ABSTRACT_TYPE
      class(ABSTRACT_TYPE), intent(inout) :: this
      real,                 intent(in   ) :: inp(3)
    end subroutine

    real elemental function intf_getScalar(this) result(laenge)
      import :: ABSTRACT_TYPE
      class(ABSTRACT_TYPE), intent(in   ) :: this
    end function

    elemental subroutine intf_setScalar(this, inp)
      import :: ABSTRACT_TYPE
      class(ABSTRACT_TYPE), intent(inout) :: this
      real,                 intent(in   ) :: inp
    end subroutine
  end interface

!=================================================================
  type, extends (ABSTRACT_TYPE) :: EXTENDED_TYPE
  contains
    procedure :: getArray     => getArray_Extended
    procedure :: getScalar    => getScalar_Extended
    procedure :: setArray     => setArray_Extended
    procedure :: setScalar    => setScalar_Extended

  end type EXTENDED_TYPE

!=================================================================
contains
!=================================================================


  pure function getArray_Extended(this) result(res)
    class(EXTENDED_TYPE), intent(in   ) :: this
    real                                :: res
  end function

  real elemental function getScalar_Extended(this)
    class(EXTENDED_TYPE), intent(in   ) :: this
  end function

  pure subroutine setArray_Extended(this, inp)
    class(EXTENDED_TYPE), intent(inout) :: this
    real,                 intent(in   ) :: inp(3)
  end subroutine

  elemental subroutine setScalar_Extended(this, inp)
    class(EXTENDED_TYPE), intent(inout) :: this
    real,                 intent(in   ) :: inp
  end subroutine setScalar_Extended

!=================================================================
end module FOO

 

0 Kudos
1 Solution
FortranFan
Honored Contributor III
1,105 Views

There appears to be a couple of issues here:

  1. I assume you meant "abstract interface" on line 16 instead of "interface abstract".  I would think the line "interface abstract" would signal to the compiler an attempt to provide a generic interface named abstract and in which case the compiler should give an error (not a warning) that all the procedures in said generic need either be all SUBROUTINE or FUNCTION procedures.  This would appear to be a bug in the compiler that it does not give such an error.
  2. If you change your code to "abstract interface", then the code compiles ok but gives "warning #6178: The return value of this FUNCTION has not been defined.   [GETSCALAR_EXTENDED]" which also seems spurious, similar to the other thread you created around the same time as this one.

View solution in original post

0 Kudos
6 Replies
FortranFan
Honored Contributor III
1,106 Views

There appears to be a couple of issues here:

  1. I assume you meant "abstract interface" on line 16 instead of "interface abstract".  I would think the line "interface abstract" would signal to the compiler an attempt to provide a generic interface named abstract and in which case the compiler should give an error (not a warning) that all the procedures in said generic need either be all SUBROUTINE or FUNCTION procedures.  This would appear to be a bug in the compiler that it does not give such an error.
  2. If you change your code to "abstract interface", then the code compiles ok but gives "warning #6178: The return value of this FUNCTION has not been defined.   [GETSCALAR_EXTENDED]" which also seems spurious, similar to the other thread you created around the same time as this one.
0 Kudos
Wolf_W_
New Contributor I
1,105 Views

Well, this was obviously my fault. As you said, changing line 16 to "abstract interface", resolves the issue. The warning #6178 seems right to me, as there is no result value given in the function, because i stripped everything unimportant.

Thank you very much FortranFan!

0 Kudos
FortranFan
Honored Contributor III
1,105 Views

Wolf W. wrote:

.. The warning #6178 seems right to me, as there is no result value given in the function..

I could be wrong but the warning #6178 seems to indicate the compiler doesn't notice the code says "real elemental function getScalar_Extended.."

0 Kudos
Lorri_M_Intel
Employee
1,105 Views

"The return value of this FUNCTION has not been defined" means that nothing has been assigned to the return value of the function.

             --Lorri

 

0 Kudos
FortranFan
Honored Contributor III
1,105 Views

Lorri Menard (Intel) wrote:

"The return value of this FUNCTION has not been defined" means that nothing has been assigned to the return value of the function.

             --Lorri

Ok, but then shouldn't the compiler issue the same warning about getArray_Extended function?

0 Kudos
Lorri_M_Intel
Employee
1,105 Views

:-)  Yes.

 

0 Kudos
Reply