This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
[tobi@marktplatz tests]$ cat reduced.f90 program Decapitation implicit none integer, parameter :: STRING_LENGTH = 80 character (len = STRING_LENGTH) :: Text_1, Text_2 Text_2 = Decap (Text_1) stop contains function Decap (String) result (New_String) character (len = *), intent(in) :: String character (len = Len(String)) :: New_String return end function Decap end program Decapitation [tobi@marktplatz tests]$ gfortran reduced.f90 f951: ../../gcc/gcc/fortran/trans-expr.c:1000: gfc_conv_function_call: Assertion `sym->ts.cl && sym->ts.cl->length && sym->ts.cl->length->expr_type == EXPR_CONSTANT' failed. reduced.f90: In function `MAIN__': reduced.f90:5: internal compiler error: Aborted Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. [tobi@marktplatz tests]$
This is different from PR15324 in that the function call is affected, not only the function itself.
Confirmed.
*** Bug 15958 has been marked as a duplicate of this bug. ***
*** Bug 16236 has been marked as a duplicate of this bug. ***
*** Bug 16941 has been marked as a duplicate of this bug. ***
Patch here: http://gcc.gnu.org/ml/fortran/2004-09/msg00253.html
The patch is wrong because it does only solve part of the problem. With the testcase from the mailing list posting referred to above, we get code like this: { logical4 D.464; char[1 .. .d] * pstr.0; pstr.0 = (char[1 .. .d] *) _gfortran_internal_malloc (.d); d (pstr.0, .d, &t1, 10); where .d is used uninitialized. If the function D from the testcase is declared external, with no interface, we hit the same assertion as without the patch.
Subject: Re: ICE with assumed length character strings tobi at gcc dot gnu dot org wrote: > If the function D from the testcase is declared external, with no interface, we > hit the same assertion as without the patch. > Ugh, messed up when editing. This is meant to read: "If the function D from the testcase is external, not contained, we hit the same assertion as without the patch."
*** Bug 19927 has been marked as a duplicate of this bug. ***
*** Bug 23654 has been marked as a duplicate of this bug. ***
Working on a patch.
Subject: Bug 15326 CVSROOT: /cvs/gcc Module name: gcc Changes by: rsandifo@gcc.gnu.org 2005-09-08 18:46:06 Modified files: gcc/fortran : ChangeLog trans-array.c trans-expr.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gfortran.dg: char_result_1.f90 char_result_2.f90 char_result_3.f90 char_result_4.f90 char_result_5.f90 char_result_6.f90 char_result_7.f90 char_result_8.f90 Log message: PR fortran/15326 * trans-array.c (gfc_add_loop_ss_code): Set ss->string_length in the GFC_SS_FUNCTION case too. * trans-expr.c (gfc_conv_function_val): Allow symbols to be bound to function pointers as well as function decls. (gfc_interface_sym_mapping, gfc_interface_mapping): New structures. (gfc_init_interface_mapping, gfc_free_interface_mapping) (gfc_get_interface_mapping_charlen, gfc_get_interface_mapping_array) (gfc_set_interface_mapping_bounds, gfc_add_interface_mapping) (gfc_finish_interface_mapping, gfc_apply_interface_mapping_to_cons) (gfc_apply_interface_mapping_to_ref) (gfc_apply_interface_mapping_to_expr) (gfc_apply_interface_mapping): New functions. (gfc_conv_function_call): Evaluate the arguments before working out where the result should go. Make the null pointer case provide the string length in parmse.string_length. Cope with non-constant string lengths, using the above functions to evaluate such lengths. Use a temporary typespec; don't assign to sym->cl->backend_decl. Don't assign to se->string_length when returning a cached array descriptor. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.540&r2=1.541 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-array.c.diff?cvsroot=gcc&r1=1.56&r2=1.57 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-expr.c.diff?cvsroot=gcc&r1=1.59&r2=1.60 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6030&r2=1.6031 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/char_result_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/char_result_2.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/char_result_3.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/char_result_4.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/char_result_5.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/char_result_6.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/char_result_7.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/char_result_8.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
Patch committed to trunk.
Not fixed in 4.0: $ cat > reduced.f90 program Decapitation implicit none integer, parameter :: STRING_LENGTH = 80 character (len = STRING_LENGTH) :: Text_1, Text_2 Text_2 = Decap (Text_1) stop contains function Decap (String) result (New_String) character (len = *), intent(in) :: String character (len = Len(String)) :: New_String return end function Decap end program Decapitation $ gfortran reduced.f90 reduced.f90: In function 'MAIN__': reduced.f90:11: internal compiler error: in gfc_conv_function_call, at fortran/trans-expr.c:1108 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. $ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.0/configure --prefix=/home/ig25 --enable-languages=c,fortran Thread model: posix gcc version 4.0.2 20050917 (prerelease)
All of these are fixed in 4.1.0. Since 4.0.2 is the last 4.0 release before a 4.1.0 release will be made, 4.0.2 and 4.0.1 were special releases for gfrotran. 4.0.3 should be a normal release for GCC and gfortran in that regressions are the only changes.
*** Bug 25012 has been marked as a duplicate of this bug. ***