Bug 18883 - ICE in gfc_finish_var_decl
Summary: ICE in gfc_finish_var_decl
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
: 19971 24503 (view as bug list)
Depends on: 15164 15326
Blocks:
  Show dependency treegraph
 
Reported: 2004-12-08 09:26 UTC by Thomas Koenig
Modified: 2006-01-01 05:34 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-04 18:20:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2004-12-08 09:26:06 UTC
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)
$
Comment 1 Andrew Pinski 2004-12-08 14:54:27 UTC
Confirmed.
Comment 2 Andrew Pinski 2004-12-08 14:56:17 UTC
Might be related to PR 15164.
Comment 3 Andrew Pinski 2005-02-16 03:31:14 UTC
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
Comment 4 Andrew Pinski 2005-02-16 03:32:08 UTC
*** Bug 19971 has been marked as a duplicate of this bug. ***
Comment 5 Volker Reichelt 2005-04-21 08:44:47 UTC
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
======================================
Comment 6 eedelman 2005-10-27 10:26:19 UTC
*** Bug 24503 has been marked as a duplicate of this bug. ***
Comment 7 eedelman 2005-10-27 10:28:37 UTC
Patch here: http://gcc.gnu.org/ml/fortran/2005-10/msg00587.html
Comment 8 eedelman 2005-10-30 22:43:49 UTC
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

Comment 9 eedelman 2005-11-11 12:18:13 UTC
Fixed on 4.1.  Not yet fixed on 4.0, because it depends on PR 15326 which hasn't been fixed for 4.0.
Comment 10 eedelman 2005-12-27 22:09:53 UTC
(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.