Bug with protected pointer

Bug with protected pointer

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
public

integer, target, public :: a = 42
integer, pointer, protected :: aa => null()

contains

subroutine alloc()
aa => a
end subroutine alloc

end module module

program program
use module
implicit none

call alloc()
write (*,'(I0)') aa
aa = 1
write (*,'(I0)') aa

end program program

6 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

So the flagged assignment statement should be assigning 1 to "a" not "aa" based on the description, correct?

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.

Steve - Intel Developer Support

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.

Steve, that is exactly the problem.  Non-pointer rules for the protected attribute are being applied to a pointer.

Ok, thank you. I reported the issue to Development.

(Internal tracking id: DPD200249513)

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!