The following program compiles without errors, but gives a segfault at runtime:

PROGRAM test_prog

  PROCEDURE(triple), POINTER :: f

  ! This works
  print *,triple(2.,4.)

  ! This creates a Segmentation Fault
  f => triple
  print *,f(2.,4.)

CONTAINS

  FUNCTION triple(a,b) RESULT(tre)
    REAL, INTENT(in) :: a, b
    REAL :: tre(2)
    tre(1) = 3.*a
    tre(2) = 3.*b
  END FUNCTION triple

END PROGRAM test_prog

Reported by Barron Bichon.


-- 
           Summary: Fortran 2003: Procedure pointers with array return value
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org


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

Reply via email to