The following code triggers an ICE even with gfortran 4.3.1: ================================================================= bash$ gfortran -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.3.1/configure --with-pkgversion='DLR MF/AP UPAS 2008-06-09' --with-bugurl=walter.zimmer@dlr.de --prefix=/local/upas/inst-devel --enable-languages=c,c++,fortran --with-gmp-include=/local/upas/compile/gmp-4.2.2 --with-gmp-lib=/local/upas/compile/gmp-4.2.2/.libs --with-mpfr-include=/local/upas/compile/mpfr-2.3.1 --with-mpfr-lib=/local/upas/compile/mpfr-2.3.1/.libs Thread model: posix gcc version 4.3.1 (DLR MF/AP UPAS 2008-06-09) bash$ cat funny.F SUBROUTINE FUNNY_STRINGS character*256 STRING CHARACTER (len=*) MY_STRING(1:3) PARAMETER ( MY_STRING = (/ "A" , "B", "C" /) ) STRING = MY_STRING(1) RETURN END bash$ gfortran -c funny.F funny.F: In function ‘funny_strings’: funny.F:1: internal compiler error: in gfc_get_symbol_decl, at fortran/trans-decl.c:1031 ================================================================= I suspect this is valid code, but at the end this is not the point as an ICE should not happen here. Maybe it's related to bug id 36322, as an array is also used there, but the line number in gfc_get_symbol_decl is different, so I suspect not. This ICE is also triggered with gfortran 4.3.0 and 4.1.2.
CONFIRM. The failing assert is: gcc_assert (!sym->value); Work around: Use the following syntax CHARACTER (len=*), PARAMETER :: MY_STRING(1:3) = (/ "A" , "B", "C" /) or explicitly give the length of the character length: CHARACTER (len=1) MY_STRING(1:3)
The workaround works fine, many thanks!
Created attachment 15758 [details] Patch; TODO: Create test cases (incl. for kind=4)
> TODO: Create test cases (incl. for kind=4) And with -std=f95: checking for equal string lengths. Also the initialization by an other parameter should be checked. I will work on a test case in the next days.
Subject: Bug 36476 Author: burnus Date: Fri Jun 13 13:04:26 2008 New Revision: 136754 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136754 Log: 2008-06-13 Tobias Burnus <burnus@net-b.de> PR fortran/36476 * decl.c (do_parm): Handle init expression for len=*. 2008-06-13 Tobias Burnus <burnus@net-b.de> PR fortran/36476 * gfortran.dg/parameter_array_init_4.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/parameter_array_init_4.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog
FIXED on the trunk (4.4.0). Thanks for the report.