This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/45170] [F2003] allocatable character lengths
- From: "kargl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 9 Aug 2011 03:48:28 +0000
- Subject: [Bug fortran/45170] [F2003] allocatable character lengths
- Auto-submitted: auto-generated
- References: <bug-45170-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45170
--- Comment #20 from kargl at gcc dot gnu.org 2011-08-09 03:48:11 UTC ---
(In reply to comment #19)
> Comment 9 states that gfortran does not yet support "function result variables
> which are character(len=:), pointer". Presumably this also implies a lack of
> support for replacing these with allocatable, deferred-length character
> variables. I'm adding the case below because it produces an ICE with gfortran
> 4.6.1:
>
> $ cat speaker.F90
> module speaker_class
> type speaker
> contains
> procedure :: speak
> end type
> contains
> function speak(this)
> class(speaker) ,intent(in) :: this
> character(:) ,allocatable :: speak
> end function
> subroutine say_something(somebody)
> class(speaker) :: somebody
> print *,somebody%speak()
> end subroutine
> end module
>
> $ gfortran -c speaker.F90
> speaker.F90: In function 'say_something':
> speaker.F90:13:0: internal compiler error: in fold_convert_loc, at
> fold-const.c:1906
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://gcc.gnu.org/bugs.html> for instructions.
It works fine if you remove all the extraneous garbage in
your example.
laptop:kargl[217] cat foo.f90
module speaker_class
contains
function speak()
character(:) , allocatable :: speak
speak = 'foo'
end function
end module
program foo
use speaker_class
print *, speak()
end program foo
laptop:kargl[218] gfc4x -o z foo.f90 && ./z
foo