http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51286

             Bug #: 51286
           Summary: function with print statement hangs when called as
                    argument of a print statement
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: stefano.bor...@ferrara.linux.it


This code hangs due to the "whatever" printing statement inside the function,
when called as an argument to print.

Wild guess is that it tries to get some lock during the Squared print, which is
already taken by the caller, but it's pure speculation. 

Tested on ifort, works as expected (no hang, two prints).

module Moo
contains
   subroutine main()

      print *, Squared(5)

   end subroutine

   function Squared(v)
      integer, intent(in) :: v
      integer :: Squared
      Squared = v*v
      print *, "whatever"
   end function
end module
program foo
   use Moo
   call main()
end program

Reply via email to