This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/32881] New: PURE attribute escapes from contained procedure


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]