Test case from a post on comp.lang.fortran. $ cat dud.f90 !From: "James Van Buskirk" <not_valid@comcast.net> !Newsgroups: comp.lang.fortran !Subject: Re: sizeof equivalent in fortran 90 programs !Message-ID: <5wytd.155433$V41.152238@attbi_s52> !Organization: Comcast Online !Date: Wed, 08 Dec 2004 08:00:01 GMT ! !"Rich Townsend" <rhdt@barVOIDtol.udel.edu> wrote in message !news:cp5v6s$8l6$1@scrotar.nss.udel.edu... ! !> Apologies for overlooking your post. ! !No problem. It just gave me an opportunity to get on my hobby !horse about initialization expressions. Regarding my hobby !horse about specification expressions, try using CVF to compile: ! module helper implicit none contains function dud(x) integer, intent(in) :: x character(selected_int_kind(x)+2) dud dud = repeat('x',len(dud)) end function dud end module helper program sik use helper implicit none integer i integer, parameter :: s(-5:5) = (/(selected_int_kind(i),i=-5,5)/) do i = -5, 5 write(*,'(4i4)') i,selected_int_kind(i),s(i),len(dud(i))-2 end do end program sik !and compare with lf95 or g95. ! !-- !write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, & !6.0134700243160014d-154/),(/'x'/)); end $ gfortran dud.f90 dud.f90: In function 'dud': dud.f90:20: internal compiler error: in gfc_finish_var_decl, at fortran/trans-decl.c:416 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. $ gfortran -v Reading specs from /home/ig25/lib/gcc/i686-pc-linux-gnu/4.0.0/specs Configured with: ../gcc/configure --prefix=/home/ig25 --enable-languages=c,c++,f95 --disable-shared : (reconfigured) ../gcc/configure --prefix=/home/ig25 --disable-shared --with-gcc-version-trigger=/home/ig25/gcc/gcc/version.c --enable-languages=c,c++,f95 --no-create --no-recursion Thread model: posix gcc version 4.0.0 20041206 (experimental) $
Confirmed.
Might be related to PR 15164.
Only the module is needed to reproduce the bug: module helper implicit none contains function dud(x) integer, intent(in) :: x character(selected_int_kind(x)+2) dud dud(1:1) = 'c' end function dud end module helper
*** Bug 19971 has been marked as a duplicate of this bug. ***
Here's a similar testcase that crashes in the same spot: ====================================== module FOO contains function BAR(X) character(*) :: X character(len(X)) :: BAR BAR = 'c' end function end ======================================
*** Bug 24503 has been marked as a duplicate of this bug. ***
Patch here: http://gcc.gnu.org/ml/fortran/2005-10/msg00587.html
Subject: Bug 18883 Author: eedelman Date: Sun Oct 30 22:43:45 2005 New Revision: 106254 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106254 Log: fortran/ 2005-10-30 Erik Edelmann <eedelman@gcc.gnu.org> PR fortran/18883 * trans-decl.c (gfc_finish_var_decl): Add decl to the current function, rather than the parent. Make assertion accept fake result variables. * trans-expr.c (gfc_conv_variable): If the character length of an ENTRY isn't set, get the length from the master function instead. testsuite 2005-10-30 Erik Edelmann <eedelman@gcc.gnu.org> PR fortran/18883 * gfortran.dg/char_result_9.f90: New. * gfortran.dg/char_result_10.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/char_result_10.f90 trunk/gcc/testsuite/gfortran.dg/char_result_9.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-decl.c trunk/gcc/fortran/trans-expr.c trunk/gcc/testsuite/ChangeLog
Fixed on 4.1. Not yet fixed on 4.0, because it depends on PR 15326 which hasn't been fixed for 4.0.
(In reply to comment #9) > Fixed on 4.1. Not yet fixed on 4.0, because it depends on PR 15326 which > hasn't been fixed for 4.0. PR 15326 will not be fixed for 4.0, I presume, so neither will this. Thus I consider this as fixed it is going to get.