The following testcase is AFAICT legal: subroutine foo () integer, pointer :: p => NULL() contains pure function bar (a) integer, intent(in) :: a integer :: bar bar = a end function bar end subroutine foo
gfortran refuses to compile it, complaining pure-escape.f90:2.23: integer, pointer :: p => NULL() 1 Error: Bad pointer object in PURE procedure at (1) Remove the pure attribute from the contained function "bar", or the "=> NULL()" initialization of the pointer, and it compiles. Both ifort and the Lahey online checker accept the code, and I can't really see how the standard could say otherwise. My guess is that gfortran thinks foo is also pure, and hence initializing p means that it's saved and thus it complains. -- Summary: PURE attribute escapes from contained procedure Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jb at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32881