Bug 34820

Summary: internal compiler error: in gfc_conv_descriptor_data_get, at fortran/trans-array.c:147
Product: gcc Reporter: Toon Moene <toon>
Component: fortranAssignee: Paul Thomas <pault>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, kostelich
Priority: P3 Keywords: ice-on-valid-code
Version: 4.3.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2008-02-19 12:09:31
Bug Depends on:    
Bug Blocks: 32834    
Attachments: Tar file with sources to evoke problem

Description Toon Moene 2008-01-16 21:45:01 UTC
The attached gzipped tar file unpacks in a directory gf.

If the definition in the Makefile of F95 is changed to invoke the latest gfortran-4.3.0, one gets the following error message:

grid_io.f90: In function 'read_grid_header':
grid_io.f90:40: internal compiler error: in gfc_conv_descriptor_data_get, at fortran/trans-array.c:147
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Toon Moene 2008-01-16 21:47:11 UTC
Created attachment 14952 [details]
Tar file with sources to evoke problem

The test case.
Comment 2 Toon Moene 2008-01-16 21:49:28 UTC
Does fail on x86-64-unknown-gnu-linux and OSX ppc (probably not relevant).
Comment 3 Tobias Burnus 2008-01-16 22:11:16 UTC
Reduced test case; works if one removes the INTENT(OUT).

    module grid_io
    type grid_index_region
      integer, allocatable::lons(:)
    end type grid_index_region
    contains
    subroutine read_grid_header()
      integer :: npiece
      type(grid_index_region),allocatable :: iregion(:)
      call read_iregion(npiece,iregion)
    end subroutine read_grid_header
    subroutine read_iregion(nproc,iregion)
      integer,intent(in)::nproc
      type(grid_index_region),intent(out)::iregion(nproc)
    end subroutine
    end module grid_io
Comment 4 Toon Moene 2008-01-16 22:19:21 UTC
Also wrong with Debian's 4.2.3 prerelease.
Comment 5 Joost VandeVondele 2008-01-17 06:12:37 UTC
with allocatable structure components, this likely is not a 'f95 only' bug (PR32834).
Comment 6 Paul Thomas 2008-01-17 06:23:07 UTC
    Toon,

I do not have time to fix this in the next day or two but this is a work around:

          type(grid_index_region),intent(out)::iregion(:)

I'll bet that with dimension nproc that no descriptor is being built for iregion.

    Cheers

    Paul

Comment 7 Paul Thomas 2008-02-19 12:09:31 UTC
I have a regtested patch for this but cannot post it until Saturday, when I am back from vacation.

Paul
Comment 8 Paul Thomas 2008-03-29 08:23:27 UTC
(In reply to comment #7)
> I have a regtested patch for this but cannot post it until Saturday, when I am
> back from vacation.
> 
> Paul

This has been delayed by the discovery of memory leaks in a number of the gfortran.dg/alloc_comp*

Watch this space.

Paul

Comment 9 Paul Thomas 2008-11-24 06:35:54 UTC
Subject: Bug 34820

Author: pault
Date: Mon Nov 24 06:34:16 2008
New Revision: 142148

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142148
Log:
2008-11-24  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34820
	* trans-expr.c (gfc_conv_function_call): Remove all code to
	deallocate intent out derived types with allocatable
	components.
	(gfc_trans_assignment_1): An assignment from a scalar to an
	array of derived types with allocatable components, requires
	a deep copy to each array element and deallocation of the
	converted rhs expression afterwards.
	* trans-array.c : Minor whitespace.
	* trans-decl.c (init_intent_out_dt): Add code to deallocate
	allocatable components of derived types with intent out.
	(generate_local_decl): If these types are unused, set them
	referenced anyway but allow the uninitialized warning.

	PR fortran/34143
	* trans-expr.c (gfc_trans_subcomponent_assign): If a conversion
	expression has a null data pointer argument, nullify the
	allocatable component.

	PR fortran/32795
	* trans-expr.c (gfc_trans_subcomponent_assign): Only nullify
	the data pointer if the source is not a variable.

2008-11-24  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34820
	* gfortran.dg/alloc_comp_constructor_6.f90 : New test.
	* gfortran.dg/alloc_comp_basics_1.f90 : Reduce expected refs to
	'builtin_free' from 24 to 18.

	PR fortran/34143
	* gfortran.dg/alloc_comp_constructor_5.f90 : New test.

	PR fortran/32795
	* gfortran.dg/alloc_comp_constructor_4.f90 : New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_2.f90
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_constructor_4.f90
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_constructor_5.f90
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_basics_1.f90

Comment 10 Paul Thomas 2008-11-29 20:43:53 UTC
Subject: Bug 34820

Author: pault
Date: Sat Nov 29 20:42:22 2008
New Revision: 142284

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142284
Log:
2008-11-24  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34820
	* trans-expr.c (gfc_conv_function_call): Remove all code to
	deallocate intent out derived types with allocatable
	components.
	(gfc_trans_assignment_1): An assignment from a scalar to an
	array of derived types with allocatable components, requires
	a deep copy to each array element and deallocation of the
	converted rhs expression afterwards.
	* trans-array.c : Minor whitespace.
	* trans-decl.c (init_intent_out_dt): Add code to deallocate
	allocatable components of derived types with intent out.
	(generate_local_decl): If these types are unused, set them
	referenced anyway but allow the uninitialized warning.

	PR fortran/34143
	* trans-expr.c (gfc_trans_subcomponent_assign): If a conversion
	expression has a null data pointer argument, nullify the
	allocatable component.

	PR fortran/32795
	* trans-expr.c (gfc_trans_subcomponent_assign): Only nullify
	the data pointer if the source is not a variable.

2008-11-24  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34820
	* gfortran.dg/alloc_comp_constructor_6.f90 : New test.
	* gfortran.dg/alloc_comp_basics_1.f90 : Reduce expected refs to
	'builtin_free' from 24 to 18.

	PR fortran/34143
	* gfortran.dg/alloc_comp_constructor_5.f90 : New test.

	PR fortran/32795
	* gfortran.dg/alloc_comp_constructor_4.f90 : New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_2.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/alloc_comp_constructor_4.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/alloc_comp_constructor_5.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/alloc_comp_constructor_6.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/trans-array.c
    branches/gcc-4_3-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_3-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/alloc_comp_basics_1.f90

Comment 11 Paul Thomas 2008-11-30 07:42:25 UTC
Fixed on trunk and 4.3

Thanks for the report

Paul