- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This is a follow on question from https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/610969 in which a compiler bug was raised regarding the treatment of protected data in modules with submodules. I've installed Visual Fortran Compiler 18.0.3.210 [IA-32] and the code snippet from the original forum post does, indeed, now, compile. But when the protected variable is part of a TYPE, it still doesn't. To illustrate, I've amended the code from the original post to include a new variable within a TYPE definition:
module mymod implicit none integer, protected :: n type mytype integer :: k end type mytype type (mytype), protected :: ty interface module subroutine set_n(i) integer, intent(in) :: i end subroutine set_n module subroutine set_k(i) integer, intent(in) :: i end subroutine set_k end interface end module mymod submodule(mymod) mymod_i contains module subroutine set_n(i) integer, intent(in) :: i n = i end subroutine set_n module subroutine set_k(i) integer, intent(in) :: i ty%k = i end subroutine set_k end submodule mymod_i program test use mymod implicit none integer :: i i = 5 call set_n(i) call set_k(i) print *,n print *,ty%k end program test
When I try and compile this, the same error is raised as in the original post:
error #7986: A use associated object that has the PROTECTED attribute shall not appear in a variable definition context.
Is this a further bug, or am I doing something wrong?
Many thanks in advance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It also doesn't like it if you assign pointers to even standard-type variables that are protected but should be SUBMODULE-accessible:
module mymod implicit none integer, protected, target :: n interface module subroutine set_n(i) integer, intent(in) :: i end subroutine set_n module subroutine set_pn end subroutine set_pn end interface end module mymod submodule(mymod) mymod_i contains module subroutine set_n(i) integer, intent(in) :: i n = i end subroutine set_n module subroutine set_pn integer, pointer :: pn pn => n end subroutine set_pn end submodule mymod_i
This produces the following compiler error:
error #7994: A use associated object that has the PROTECTED attribute shall not appear as a target in a pointer-assignment-stmt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've logged it with support. I still think it's a compiler bug. In the original post from https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/610969 a very similar problem was identified as such and the compiler fixed accordingly.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page