hidden text to trigger early load of fonts ПродукцияПродукцияПродукцияПродукция Các sản phẩmCác sản phẩmCác sản phẩmCác sản phẩm المنتجاتالمنتجاتالمنتجاتالمنتجات מוצריםמוצריםמוצריםמוצרים
Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Bug with protected pointer

Brian1
초급자
1,143 조회수

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

0 포인트
5 응답
Kevin_D_Intel
직원
1,143 조회수

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

0 포인트
Steven_L_Intel1
1,143 조회수

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.

0 포인트
Brian1
초급자
1,143 조회수

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.

0 포인트
Brian1
초급자
1,143 조회수

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

0 포인트
Kevin_D_Intel
직원
1,143 조회수

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

(Internal tracking id: DPD200249513)

0 포인트
응답