Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 15326
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Tobias Schlüter <Tobias.Schlueter@physik.uni-muenchen.de>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 15326 depends on: Show dependency tree
Show dependency graph
Bug 15326 blocks: 15809 18883 19242 19276 19292 22518

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2005-08-31 20:42 Opened: 2004-05-06 16:48
[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]$

------- Comment #1 From Tobias Schlüter 2004-05-06 17:08 -------
This is different from PR15324 in that the function call is affected, not only
the function itself.

------- Comment #2 From Andrew Pinski 2004-05-06 18:02 -------
Confirmed.

------- Comment #3 From Andrew Pinski 2004-06-13 09:25 -------
*** Bug 15958 has been marked as a duplicate of this bug. ***

------- Comment #4 From Andrew Pinski 2004-06-27 20:29 -------
*** Bug 16236 has been marked as a duplicate of this bug. ***

------- Comment #5 From Andrew Pinski 2004-08-09 15:56 -------
*** Bug 16941 has been marked as a duplicate of this bug. ***

------- Comment #6 From Tobias Schlüter 2004-09-25 15:04 -------
Patch here: http://gcc.gnu.org/ml/fortran/2004-09/msg00253.html

------- Comment #7 From Tobias Schlüter 2004-10-10 21:04 -------
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.

------- Comment #8 From Tobias Schlüter 2004-10-10 21:08 -------
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."


------- Comment #9 From Andrew Pinski 2005-02-12 16:56 -------
*** Bug 19927 has been marked as a duplicate of this bug. ***

------- Comment #10 From Andrew Pinski 2005-08-31 15:15 -------
*** Bug 23654 has been marked as a duplicate of this bug. ***

------- Comment #11 From rsandifo@gcc.gnu.org 2005-08-31 20:42 -------
Working on a patch.

------- Comment #12 From CVS Commits 2005-09-08 18:46 -------
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


------- Comment #13 From rsandifo@gcc.gnu.org 2005-09-08 18:51 -------
Patch committed to trunk.

------- Comment #14 From Thomas Koenig 2005-09-18 19:52 -------
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)

------- Comment #15 From Andrew Pinski 2005-09-18 20:27 -------
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.

------- Comment #16 From Andrew Pinski 2005-11-24 06:06 -------
*** Bug 25012 has been marked as a duplicate of this bug. ***

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug