There are known problems with attempts at folding TRANSFER in constant
expressions.  However, the following code doesn't involve this, and should work
properly even if folding of TRANSFER simply bails out without attempting to
fold anything.  Instead, it gives an ICE (in the middle-end, not in the Fortran
front-end).

debian-gfortran:~/test> more awgrey2.f90
function NumOccurances(string,chr) result(n)
  character(*),intent(in) :: string
  character(1),intent(in) :: chr
!
! return number of occurances of character in given string
!
    n=count(transfer(string,char(1),len(string))==chr)
  return
end

debian-gfortran:~/test> ~/bin-trunk/bin/gfortran awgrey2.f90
awgrey2.f90: In function 'numoccurances':
awgrey2.f90:1: internal compiler error: in fold_binary, at fold-const.c:8999
Please submit a full bug report,

debian-gfortran:~/test> ~/bin-trunk/bin/gfortran --version
GNU Fortran (GCC) 4.3.0 20070307 (experimental)


-- 
           Summary: ICE on count(transfer(...)...), with non-constant
                    transfer arguments.
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: brooks at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu


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

Reply via email to