http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46122
Summary: PROTECTED check too strict Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org gfortran rejects valid <protected_pointer>%<component> references, cf. "OK 3" and "OK 4" below. The test case was created by Jared Ahern and the issue was reported to http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/6a866eb893ad8473 Note: The OK/Invalid lines are according to my understanding; no guarantee that those are correct. MODULE amod IMPLICIT NONE TYPE foo INTEGER :: i = 4 INTEGER, POINTER :: j => NULL() END TYPE foo TYPE(foo), SAVE, PROTECTED :: a TYPE(foo), SAVE, PROTECTED, POINTER :: b INTEGER, SAVE, PROTECTED :: i = 5 INTEGER, SAVE, PROTECTED, POINTER :: j => NULL() contains subroutine alloc() allocate(b,j) end subroutine alloc END MODULE amod PROGRAM test USE amod IMPLICIT NONE INTEGER, TARGET :: k TYPE(foo), TARGET :: c k = 2 ! local c%i = 9 ! local call alloc() ! In parentheses: compiler gives error for that line ! gfortran 4.6/Oct, g95 Aug 2010, NAG 5.1, ifort 11.1, ! pathf95 3.2.99, PGI 10.5 (compiles without error), crayftn i = k ! Invalid 1 (gfortran NAG g95 ifort pathf95 cray) j => k ! Invalid 2 (gfortran g95 ifort pathf95 cray) j = 3 ! OK 1 ( ifort pathf95 cray) a = c ! Invalid 3 (gfortran NAG g95 ifort pathf95 cray) a%i = k ! Invalid 4 (gfortran NAG g95 ifort pathf95 cray) a%j => k ! Invalid 5 (gfortran NAG g95 ifort pathf95 cray) a%j = 5 ! OK 2 ( g95 ifort pathf95 cray) b => c ! Invalid 6 (gfortran g95 ifort pathf95 cray) b%i = k ! OK 3 (gfortran ifort [bug] cray) b%j => k ! OK 4 (gfortran g95 ifort [bug] cray) b%j = 5 ! OK 5 ( ifort [bug] cray) END PROGRAM test