[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647 --- Comment #11 from Tobias Burnus burnus at gcc dot gnu.org 2010-10-13 13:21:40 UTC --- (In reply to comment #10) allocate(a1, a1%b1, a1%b1%c1) This ALLOCATE statement is INVALID! It violates the following: An allocate-object [...] shall not depend [...] on the [...] allocation status [...] of any allocate-object in the same ALLOCATE statement. (F2008, 6.7.1 ALLOCATE statement first paragraph after C644.) Solution: Write it as allocate(a1) allocate(a1%b1) allocate(a1%b1%c1) The test case still fails: For the DEALLOCATE statement one wrongly gets the error that the variable is not allocated. * * * Cf. also Janus' patch for this PR (which does not yet fix this DEALLOCATE issue): http://gcc.gnu.org/ml/fortran/2010-10/msg00155.html
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #10 from dominiq at lps dot ens dot fr 2010-09-02 14:49 --- The tests in the different comments seem to pass since some time. The behavior of the derived test module m type st integer , allocatable :: c1 end type st type t1 type(st), allocatable :: b1 end type t1 end module m use m type(t1) :: a1, aa1(:) allocatable :: a1, aa1 if(allocated(a1)) call abort() if(allocated(aa1)) call abort() print *, 'now allocate' allocate(a1, a1%b1, a1%b1%c1) print *, allocated(a1), allocated(a1%b1), allocated(a1%b1%c1) a1%b1%c1 = 1 print *, a1%b1%c1 deallocate(a1%b1%c1) print *, allocated(a1), allocated(a1%b1), allocated(a1%b1%c1) deallocate(a1%b1) end has changed with r163744. Before one got [macbook] f90/bug% a.out now allocate Segmentation fault Now I get: [macbook] f90/bug% a.out now allocate T T T 1 T T F At line 25 of file pr42647_1_pass_1_red_1.f90 Fortran runtime error: Attempt to DEALLOCATE unallocated 'a1' -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #9 from dominiq at lps dot ens dot fr 2010-05-16 14:40 --- (In reply to comment #8) This is fixed by this patchlet (which is part of patch in comment #1): This patch breaks gfortran.dg/allocatable_scalar_9.f90 (Segmentation fault) and some variants I have in my tests. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #5 from dominiq at lps dot ens dot fr 2010-05-15 21:25 --- See also pr44154. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #6 from janus at gcc dot gnu dot org 2010-05-15 22:03 --- Subject: Bug 42647 Author: janus Date: Sat May 15 22:03:09 2010 New Revision: 159445 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=159445 Log: 2010-05-15 Janus Weil ja...@gcc.gnu.org PR fortran/44154 PR fortran/42647 * trans-decl.c (gfc_trans_deferred_vars): Modify ordering of if branches. 2010-05-15 Janus Weil ja...@gcc.gnu.org PR fortran/44154 PR fortran/42647 * gfortran.dg/allocatable_scalar_9.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/allocatable_scalar_9.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-decl.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #7 from janus at gcc dot gnu dot org 2010-05-15 22:16 --- r159445 should fix all the initialization trouble. Comment #2/#3 has been included as a test case. For the automatic deallocation there is be a problem remaining: In comment #0, a itself is now automatically deallocated, but not a%d any more. -- janus at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2010-05-15 22:16:55 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #8 from janus at gcc dot gnu dot org 2010-05-15 22:29 --- (In reply to comment #7) For the automatic deallocation there is be a problem remaining: In comment #0, a itself is now automatically deallocated, but not a%d any more. This is fixed by this patchlet (which is part of patch in comment #1): Index: gcc/fortran/trans-decl.c === --- gcc/fortran/trans-decl.c(revision 159445) +++ gcc/fortran/trans-decl.c(working copy) @@ -3272,6 +3272,9 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, tr gfc_se se; stmtblock_t block; + if (sym_has_alloc_comp) + fnbody = gfc_trans_deferred_array (sym, fnbody); + e = gfc_lval_expr_from_sym (sym); if (sym-ts.type == BT_CLASS) gfc_add_component_ref (e, $data); Also the use-association issue still needs to be taken care of. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
-- burnus at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|burnus at gcc dot gnu dot |unassigned at gcc dot gnu |org |dot org Status|ASSIGNED|UNCONFIRMED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #4 from dominiq at lps dot ens dot fr 2010-01-10 15:36 --- The patch in comment #1 fixes the test in comment#0, bootstrapped, regtested, and passed my tests. I have split the tests in comment#2 and #3 in two: module m type st integer , allocatable :: a1 end type st type at integer , allocatable :: a2(:) end type at type t1 type(st), allocatable :: b1 end type t1 type t3 type(at), allocatable :: b3 end type t3 end module m use m type(t1) :: na1, a1, aa1(:) type(t3) :: na3, a3, aa3(:) allocatable :: a1, a3, aa1, aa3 if(allocated(a1)) call abort() if(allocated(a3)) call abort() if(allocated(aa1)) call abort() if(allocated(aa3)) call abort() if(allocated(na1%b1)) call abort() if(allocated(na3%b3)) call abort() print *, 'end' end and module m type st integer , allocatable :: a1 end type st type at integer , allocatable :: a2(:) end type at type t2 type(st), allocatable :: b2(:) end type t2 type t4 type(at), allocatable :: b4(:) end type t4 end module m use m type(t2) :: na2, a2, aa2(:) type(t4) :: na4, a4, aa4(:) allocatable :: a2, a4, aa2, aa4 !if(allocated(a2)) call abort() !if(allocated(a4)) call abort() if(allocated(aa2)) call abort() if(allocated(aa4)) call abort() if(allocated(na2%b2)) call abort() if(allocated(na4%b4)) call abort() print *, 'end' end As such, both pass with the patch, while the first one gives a Segmentation fault before the print without the patch (the second pass). If I remove one of the '!', the test fails with Segmentation fault AFTER the print with or without the patch. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #1 from burnus at gcc dot gnu dot org 2010-01-09 17:34 --- Created an attachment (id=19524) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19524action=view) Patch - fixes also use-assoc sllocatable scalars -- burnus at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |burnus at gcc dot gnu dot |dot org |org Status|UNCONFIRMED |ASSIGNED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #2 from burnus at gcc dot gnu dot org 2010-01-09 21:29 --- And of cause it still does not work: module m type st integer , allocatable :: a1 end type st type at integer , allocatable :: a2(:) end type at type t1 type(st), allocatable :: b1 end type t1 type t2 type(st), allocatable :: b2(:) end type t2 type t3 type(at), allocatable :: b3 end type t3 type t4 type(at), allocatable :: b4(:) end type t4 end module m -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647
[Bug fortran/42647] Missed initialization/dealloc of allocatable scalar DT with allocatable component
--- Comment #3 from burnus at gcc dot gnu dot org 2010-01-09 21:30 --- use m type(t1) :: na1, a1, aa1(:) type(t2) :: na2, a2, aa2(:) type(t3) :: na3, a3, aa3(:) type(t4) :: na4, a4, aa4(:) allocatable :: a1, a2, a3, a4, aa1, aa2, aa3,aa4 if(allocated(a1)) call abort() if(allocated(a2)) call abort() if(allocated(a3)) call abort() if(allocated(a4)) call abort() if(allocated(aa1)) call abort() if(allocated(aa2)) call abort() if(allocated(aa3)) call abort() if(allocated(aa4)) call abort() if(allocated(na1%b1)) call abort() if(allocated(na2%b2)) call abort() if(allocated(na3%b3)) call abort() if(allocated(na4%b4)) call abort() end -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42647