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

Problems with 18.1 and ALIAS attribute

Wolf_W_
New Contributor I
589 Views

Dear Fortran Forum,

i got a problem with the ifort 18 Update 1 Compiler. It seems the way the alias attribute is handled in submodules has changed. I can't get my code to compile with the alias attribute. I need it, to keep downward compatibility of the dll. Is this new behavior intended or a bug?

Greetings
Wolf

module M_MOD
  implicit none

  type T_TYPE

    contains
!    procedure, nopass :: foo ! This works without ALIAS
    procedure, nopass :: foo_renamed=>foo ! This works in none of my tests with 18.1

  end type

interface
  module subroutine foo()
!    !DEC$ ATTRIBUTES ALIAS:"foo" :: foo
    !DEC$ ATTRIBUTES DLLEXPORT :: foo

  end subroutine
end interface

end module


submodule (M_MOD) S_MOD
  implicit none

contains
  module subroutine foo()
    ! IFORT 16 to 18.0 give "error #7286: This symbol has multiply declared DEC$ ATTRIBUTES ALIAS attribute.   [FOO]"
!    !DEC$ ATTRIBUTES ALIAS:"foo" :: foo ! Until 18.1 it worked without this line
    !DEC$ ATTRIBUTES DLLEXPORT :: foo

  end subroutine

end submodule


module M_USING_M_MOD
  use M_MOD
  implicit none

contains

  subroutine bar()

    type(T_TYPE) :: T_TYPE_INSTANCE

    ! IFORT 18.1 gives Link error: "error LNK2019: unresolved external symbol "M_MOD_mp_FOO" in function "M_USING_M_MOD_mp_BAR""
!    call T_TYPE_INSTANCE%foo()

    ! IFORT 18.1 gives Link error: "error LNK2019: unresolved external symbol "M_MOD_mp_FOO_RENAMED" in function "M_USING_M_MOD_mp_BAR""
    call T_TYPE_INSTANCE%foo_renamed()

  end subroutine

end module

 

0 Kudos
4 Replies
Lorri_M_Intel
Employee
589 Views

I'm sorry, I can't understand what you want to happen.

What I think you want, is for submodule routine named "foo" to have the external name "foo" (rather than the fully qualified module name).

What I can't easily work out, is which commented out code paths are good, which are problematic.

We did fix an issue with the  multiple ALIAS declarations, so yes, there have been changes in this area.

Can you post a version that worked in 18.0 but does not work in 18.1?  Maybe that would be clearer for me.

            thanks --

                                          --Lorri

 

0 Kudos
Wolf_W_
New Contributor I
589 Views

I'm sorry, that i couldn't make things clear...
Yes i want "foo" to have the external name foo - i can work around this problem in most of my code, but i think this is a compiler bug. The ALIAS seems to be broken, when used with type bound procedures in submodules.

I just realized, that it fails without the renaming, too.

!This works in <=18.0
module M_MOD
  implicit none

  type T_TYPE

    contains
    procedure, nopass :: foo 

  end type

interface
  module subroutine foo()
    !DEC$ ATTRIBUTES ALIAS:"foo" :: foo
    !DEC$ ATTRIBUTES DLLEXPORT :: foo

  end subroutine
end interface

end module


submodule (M_MOD) S_MOD
  implicit none

contains
  module subroutine foo()
    !DEC$ ATTRIBUTES DLLEXPORT :: foo

  end subroutine

end submodule


module M_USING_M_MOD
  use M_MOD
  implicit none

contains

  subroutine bar()

    type(T_TYPE) :: T_TYPE_INSTANCE

    call T_TYPE_INSTANCE%foo()

  end subroutine

end module

-----

module M_MOD
  implicit none

  type T_TYPE

    contains
    procedure, nopass :: foo

  end type

interface
  module subroutine foo()
    !DEC$ ATTRIBUTES ALIAS:"foo" :: foo
    !DEC$ ATTRIBUTES DLLEXPORT :: foo

  end subroutine
end interface

end module


submodule (M_MOD) S_MOD
  implicit none

contains
  module subroutine foo()
    !DEC$ ATTRIBUTES ALIAS:"foo" :: foo
    !DEC$ ATTRIBUTES DLLEXPORT :: foo

  end subroutine

end submodule


module M_USING_M_MOD
  use M_MOD
  implicit none

contains

  subroutine bar()

    type(T_TYPE) :: T_TYPE_INSTANCE

!    call foo() ! But it works, when not calling the type bound procedure
    call T_TYPE_INSTANCE%foo()

  end subroutine

end module

Greetings
Wolf

0 Kudos
andrew_4619
Honored Contributor III
589 Views

As a matter of interest does bind(c, name='foo') work as that is surely better than using the not standard "alias"? 

0 Kudos
Steve_Lionel
Honored Contributor III
589 Views

The difference with BIND(C,NAME=) is that it behaves as if you had added DECORATE to the ALIAS attribute, so with 32-bit you get a leading underscore.

0 Kudos
Reply