- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have found a bug with protected pointers in the Intel Fortran compiler.
Section 5.1.2.12, lines 3-7 of the Fortran 2003 standard says, basically, that the association status of a pointer with the protected attribute cannot be changed outside of the module in which it is declared. However, it is valid to define an object which is pointed to by such a pointer outside of the module.
For some reason I am unable to attach a file to this message, so I've included the source code at the end of this post. I tried compiling with Intel Fortran 12.1, 13.1, and 14.0. All of them stop with the error message:
bug.f90(23): error #7986: A use associated object that has the PROTECTED attribute shall not appear in a variable definition context. [AA]
aa = 1
--^
compilation aborted for bug.f90 (code 1)
The bug is that the Intel Fortran compiler is treating a protected pointer like a protected object, i.e. it is preventing it from being defined outside of the module.
module module
implicit none
publicinteger, target, public :: a = 42
integer, pointer, protected :: aa => null()contains
subroutine alloc()
aa => a
end subroutine allocend module module
program program
use module
implicit nonecall alloc()
write (*,'(I0)') aa
aa = 1
write (*,'(I0)') aaend program program
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So the flagged assignment statement should be assigning 1 to "a" not "aa" based on the description, correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The description of PROTECTED changed somewhat in Fortran 2008 but Brian's complaint is still valid. F2008 says:
"A pointer that has the PROTECTED attribute and is accessed by use association shall not appear in a pointer association context (16.6.8)." [F2008 C552]
It looks to me as if the compiler is applying non-pointer rules here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By the way, I believe this program remains valid and should produce the same output even if "a" is declared private in the module, but this is a separate matter from the bug I am reporting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, that is exactly the problem. Non-pointer rules for the protected attribute are being applied to a pointer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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