From
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/d710371aed91e75f#

The following program is invalid. This is diagnosed at compile time by ifort,

test.f90(19): error #6832: This passed length character name has been used in
an invalid context.   [BIGFUNC]
   character(i) bigfunc
----------------^

and NAG f95

Error: test.f90: CHARACTER*1024 function BIGFUNC referenced with non-constant
length from LEVEL1

and open95

openf95-916 openf95: ERROR LEVEL1, File = test.f90, Line = 19, Column = 17
  "BIGFUNC" has a variable length character result, therefore it must have an
explicit interface.

and g95

   character(i) bigfunc
                1
Error: Nonconstant character function 'bigfunc' at (1) must have an explicit
interface

But not in gfortran - even not with -fwhole-file -fcheck=all.

program main
   implicit none
   character(4) level1
   character(4) answer
   integer i

   do i = 1024, 1, -1023
      write(*,'(a,i0)') 'Invoking level1 with i = ', i
      answer = level1(i)
      write(*,'(a)') 'Back from level1'
      write(*,'(a,i0,2a)') 'i = ', i, ', answer = ', answer
   end do
end program main

function level1(i)
   implicit none
   integer i
   character(4) level1
   character(i) bigfunc

   level1 = bigfunc()
end function level1

function bigfunc()
   implicit none
   character(1024) bigfunc

   bigfunc = repeat('b',len(bigfunc))
end function bigfunc


-- 
           Summary: Missing explicit interface for variable-length character
                    functions
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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

Reply via email to