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

EQUIVALENCE and PUBLIC access (bug?)

Thomas_F_1
Beginner
649 Views

The following code does not compile unless I remove the equivalence statement:

module one
implicit none
save

type mytype
  sequence
  integer :: i = 42
  integer :: j = 67
  integer :: k = 76
end type

! Instantiate sequence type
type (mytype) :: me

! Establish common block
integer :: i,j,k
common /xx/ i,j,k 

! Eqv type with common
equivalence (me, i)

end module one

!-----------------------------------------------------------

module two

! Restrict access through seq type only (not /xx/)
use one, only: me
implicit none
private

! Allow access through use association
public :: me

contains

subroutine sub
print *, "I = ",me%i
end subroutine

end module two
!-----------------------------------------------------------

program test
use two
implicit none

print *, "I = ",me%i

end program
!-----------------------------------------------------------

The compiler error is as follows:

test.f90(49): error #6404: This name does not have a type, and must have an explicit type.   [ME]

print *, "I = ",me%i

----------------^

test.f90(49): error #6460: This is not a field name that is defined in the encompassing structure.  

print *, "I = ",me%i

-------------------^

Note that it does not complain about the usage on line 39. I can't find anything in the texts that I have that would suggest this isn't allowed. Without the equivalence statement, everything compiles and runs just fine, and the "public" ME variable accessible through use association works as expected. Could this be a flaw in the compiler? Or am I missing something in the standard?

0 Kudos
4 Replies
Thomas_F_1
Beginner
649 Views

I forgot to mention that if I remove the PRIVATE and PUBLIC statements, the code compiles fine, but then the entirety of module two is public, which is not what I want.

0 Kudos
Steven_L_Intel1
Employee
649 Views

Thanks - I think this one is fixed but I need to check...

0 Kudos
Steven_L_Intel1
Employee
649 Views

Yes, this is fixed for the 15.0 release later this year. The fix is not in the current beta.

0 Kudos
Thomas_F_1
Beginner
649 Views

Good to hear. I look forward to the update.

0 Kudos
Reply