- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks - I think this one is fixed but I need to check...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this is fixed for the 15.0 release later this year. The fix is not in the current beta.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good to hear. I look forward to the update.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page