From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17336 invoked by alias); 5 Jun 2010 10:40:49 -0000 Received: (qmail 17203 invoked by uid 48); 5 Jun 2010 10:40:33 -0000 Date: Sat, 05 Jun 2010 10:40:00 -0000 Message-ID: <20100605104033.17202.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/43895] [OOP] internal compiler error: verify_ssa failed In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pault at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-06/txt/msg00557.txt.bz2 ------- Comment #12 from pault at gcc dot gnu dot org 2010-06-05 10:40 ------- (In reply to comment #11) OK, all this has a simple explanation. A revamped version of the original testcase segfaults in runtime, at -O0. ! { dg-do compile } ! Test the fix for PR43895, in which the dummy 'a' was not ! dereferenced for the deallocation of component 'a', as required ! for INTENT(OUT). ! ! Contributed by Salvatore Filippone ! module d_mat_mod type :: base_sparse_mat end type base_sparse_mat type, extends(base_sparse_mat) :: d_base_sparse_mat integer :: i end type d_base_sparse_mat type :: d_sparse_mat class(d_base_sparse_mat), allocatable :: a end type d_sparse_mat end module d_mat_mod use d_mat_mod type(d_sparse_mat) :: b allocate (b%a) b%a%i = 42 call bug14 (b) if (allocated (b%a)) call abort contains subroutine bug14(a) implicit none type(d_sparse_mat), intent(out) :: a end subroutine bug14 end ! { dg-final { cleanup-modules "d_mat_mod " } } The reason is quite clear from the code below: bug14 (struct d_sparse_mat & restrict a) { if (a.a.$data != 0B) { __builtin_free ((void *) a.a.$data); } a.a.$data = 0B; } The dummy 'a' needs dereferencing, thus... bug14 (struct d_sparse_mat & restrict a) { if (a->a.$data != 0B) { __builtin_free ((void *) a->a.$data); } a->a.$data = 0B; } This patch is regtesting right now: Index: /svn/trunk/gcc/fortran/trans-array.c =================================================================== *** /svn/trunk/gcc/fortran/trans-array.c (revision 159851) --- /svn/trunk/gcc/fortran/trans-array.c (working copy) *************** structure_alloc_comps (gfc_symbol * der_ *** 5951,5957 **** gfc_init_block (&fnblock); ! if (POINTER_TYPE_P (TREE_TYPE (decl)) && rank != 0) decl = build_fold_indirect_ref_loc (input_location, decl); --- 5951,5958 ---- gfc_init_block (&fnblock); ! if ((POINTER_TYPE_P (TREE_TYPE (decl)) && rank != 0) ! || (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE && rank == 0)) decl = build_fold_indirect_ref_loc (input_location, decl); Cheers Paul -- pault at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org |dot org | Status|NEW |ASSIGNED Last reconfirmed|2010-04-26 15:04:01 |2010-06-05 10:40:32 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43895