Bug#401496: gfortran-4.1 bug / ICE in gfc_conv_constant at fortran-trans-const.c:348
Package: gfortran-4.1
Version: 4.1.1-19
The source code below generates an internal compiler error. The error
is somehow related with to the two initialization of the two constants
n1 and n2. The exact command-line arguments used appear to be irrelevant.
Gfortran version report and compiler error are in the code comments.
-Jonathan
PS. The loadcfg() subroutine is probably innocent, but I forgot to
delete it and I'm not running under Linux at the moment to verify it.
! ----------------------------------------------------------------------
!~/source> gfortran -c testbug.f90
!testbug.f90: In function 'xstrcmp':
!testbug.f90:11: internal compiler error: in gfc_conv_constant, at
fortran/trans-const.c:348
!Please submit a full bug report,
!with preprocessed source if appropriate.
!See <URL:http://gcc.gnu.org/bugs.html> for instructions.
!For Debian GNU/Linux specific bug reporting instructions,
!see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>.
!
!~/source> gfortran --version
!GNU Fortran 95 (GCC) 4.1.2 20061028 (prerelease) (Debian 4.1.1-19)
!Copyright (C) 2006 Free Software Foundation, Inc.
!
!GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
!You may redistribute copies of GNU Fortran
!under the terms of the GNU General Public License.
!For more information about these matters, see the file named COPYING
! ----------------------------------------------------------------------
! ----------------------------------------------------------------------
! Load in configuration files.
module cfgfile
! Module variables used to be here
contains
! --------------------------------------------------------------------
! Read parameters out of the file - probably irrelevant.
subroutine loadcfg(fname)
character*(*), intent(in) :: fname
open(unit=2, file=fname, status='old', iostat=ierr)
! File parser used to be here
close(2)
return
end subroutine loadcfg
! --------------------------------------------------------------------
! Compare 2 strings - THIS CAUSES A COMPILER CRASH
integer function xstrcmp(s1, s2)
implicit none
character*(*), intent(in) :: s1, s2
integer :: i, n1 = len(s1), n2 = len(s2)
! If I don't ever reference n1,n2 then I won't have a problem.
n1 = 1
n2 = 2
! Comparison code used to be here
xstrcmp = -1
return
end function xstrcmp
end module cfgfile
! ----------------------------------------------------------------------
! MAIN PROGRAM
program testcfg
use cfgfile
call loadcfg('test.cfg')
return
end program testcfg
Reply to: