From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99522 invoked by alias); 17 Jul 2015 10:17:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 99504 invoked by uid 89); 17 Jul 2015 10:17:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 17 Jul 2015 10:17:13 +0000 Received: from vepi2 ([84.63.202.252]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0LZiQy-1YWqa01YsO-00lXZB; Fri, 17 Jul 2015 12:17:08 +0200 Date: Fri, 17 Jul 2015 11:01:00 -0000 From: Andre Vehreschild To: Paul Richard Thomas Cc: Mikael Morin , GCC-Patches-ML , GCC-Fortran-ML Subject: Re: [Patch, Fortran, 66035, v2] [5/6 Regression] gfortran ICE segfault Message-ID: <20150717121707.7f1a9e2f@vepi2> In-Reply-To: References: <20150508152950.182a4c1a@gmx.de> <554F573D.9030909@sfr.fr> <20150511124006.62b5c58b@gmx.de> <20150706135457.429f0e35@vepi2> <559FF71B.1040302@sfr.fr> <20150711140859.5ba7d10c@vepi2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/+V8VDZwbnFjV.ClkU8wlid8" X-UI-Out-Filterresults: notjunk:1;V01:K0:2cJ92GwyzU4=:k8MhssX+eVvSacACPRHCDJ kHuuwzgC8fZ+q1kEouENe8BW9Ck5TOWstz1ELgN1NoA7VO+bULsN9l4UiDIV9ZHbk6ITOQDhB YwsxKNpE76m2tFH9FwitageHphOBOJik7rnLSnTD579lPdRJQvfcoYZXak5oWmMo7lPOJ5LYj bX/uSgBvALM/7ZRGqX0JT6AsMbInLB4Rq4qYfPeyPgjIitX6t3TBf1Z8NvoZT+hgSLD254eTy VbcgLhjD6ADtdMKlPkekqP5lTB6/v7JIyvlyh7m8FHgVAYOuajHQYd8AG7rdfDpv8/gejnupk S4Zx7luddMXjoMcKnyB5jy5xOU7ACsQGJBNyIaP9bdwg9PQ3J+e6CSLFij9UwWK0T0PJTUdlR ESsRgVL+aHgbWHJzTiddLRGb22zU0fxGDAuolRaB02OaKw8jc/erBa0xcpfq+nNJ6jvyxo5LP Mw5qPY609B1DZg//TacbKlP8unPZktpNqxUmC3JthTOsK5hFaPggFcKGP+W7Bxvx1GAVx0Gkr v1a0YPgoU5SxuKzqSWlcg1pVnMx0woe5TBlJVILhOa6RIaDJJo8/EgCxXBzdzBq2p/U+0jF3q 7AMZHfClZ1sjEnLaoHjaiZf4qOg5RPSE6YXUaLUEJcta5tAtXvAl07RTWf8YIfJvtxfx1fFhU 8smvlp61etNToVq8CcPbq1ecDgu+ELBdkaJkOlIDKznjj1w== X-SW-Source: 2015-07/txt/msg01504.txt.bz2 --MP_/+V8VDZwbnFjV.ClkU8wlid8 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 2469 Hi Paul, thanks for the review, commited as r225928. Regards, Andre On Wed, 15 Jul 2015 13:40:29 +0200 Paul Richard Thomas wrote: > Dear Andre, > > I am still in the bizarre situation that the testcase compiles and > runs correctly on a clean trunk! > > That said, the patch applies cleanly and, at very least from my point > of view, does not do any harm :-) > > OK for trunk > > Thanks for the patch > > Paul > > On 11 July 2015 at 14:08, Andre Vehreschild wrote: > > Hi Mikael, > > > >> > @@ -7030,7 +7053,8 @@ gfc_trans_subcomponent_assign (tree dest, > >> > gfc_component * cm, gfc_expr * expr, gfc_add_expr_to_block (&block, tmp); > >> > } > >> > else if (init && (cm->attr.allocatable > >> > - || (cm->ts.type == BT_CLASS && CLASS_DATA > >> > (cm)->attr.allocatable))) > >> > + || (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable > >> > + && expr->ts.type != BT_CLASS))) > >> > { > >> > /* Take care about non-array allocatable components here. The > >> > alloc_* routine below is motivated by the alloc_scalar_allocatable_for_ > >> > @@ -7074,6 +7098,14 @@ gfc_trans_subcomponent_assign (tree dest, > >> > gfc_component * cm, gfc_expr * expr, tmp = gfc_build_memcpy_call (tmp, > >> > se.expr, size); gfc_add_expr_to_block (&block, tmp); > >> > } > >> > + else if (cm->ts.type == BT_CLASS && expr->ts.type == BT_CLASS) > >> > + { > >> > + tmp = gfc_copy_class_to_class (se.expr, dest, integer_one_node, > >> > + CLASS_DATA > >> > (cm)->attr.unlimited_polymorphic); > >> > + gfc_add_expr_to_block (&block, tmp); > >> > + gfc_add_modify (&block, gfc_class_vptr_get (dest), > >> > + gfc_class_vptr_get (se.expr)); > >> > + } > >> > else > >> > gfc_add_modify (&block, tmp, > >> > fold_convert (TREE_TYPE (tmp), se.expr)); > >> But this hunk is canceled by the one before, isn't it? > >> I mean, If the condition here is true, the condition before was false? > > > > You are absolutely right. The second hunk is dead code and removed in the > > attached patch. That must have been the first attempt to address the issue > > and later on I did not perceive that it was useless. Sorry for that. > > > > Regards, > > Andre > > -- > > Andre Vehreschild * Email: vehre ad gmx dot de > > > -- Andre Vehreschild * Email: vehre ad gmx dot de --MP_/+V8VDZwbnFjV.ClkU8wlid8 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=submit.diff Content-length: 3598 Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 225927) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,15 @@ +2015-07-17 Andre Vehreschild + + PR fortran/66035 + * trans-expr.c (alloc_scalar_allocatable_for_subcomponent_assignment): + Compute the size to allocate for class and derived type objects + correclty. + (gfc_trans_subcomponent_assign): Only allocate memory for a + component when the object to assign is not an allocatable class + object (the memory is already present for allocatable class objects). + Furthermore use copy_class_to_class for assigning the rhs to the + component (may happen for dummy class objects on the rhs). + 2015-07-17 Mikael Morin Dominique d'Humieres Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (Revision 225927) +++ gcc/fortran/trans-expr.c (Arbeitskopie) @@ -6969,6 +6969,29 @@ TREE_TYPE (tmp), tmp, fold_convert (TREE_TYPE (tmp), size)); } + else if (cm->ts.type == BT_CLASS) + { + gcc_assert (expr2->ts.type == BT_CLASS || expr2->ts.type == BT_DERIVED); + if (expr2->ts.type == BT_DERIVED) + { + tmp = gfc_get_symbol_decl (expr2->ts.u.derived); + size = TYPE_SIZE_UNIT (tmp); + } + else + { + gfc_expr *e2vtab; + gfc_se se; + e2vtab = gfc_find_and_cut_at_last_class_ref (expr2); + gfc_add_vptr_component (e2vtab); + gfc_add_size_component (e2vtab); + gfc_init_se (&se, NULL); + gfc_conv_expr (&se, e2vtab); + gfc_add_block_to_block (block, &se.pre); + size = fold_convert (size_type_node, se.expr); + gfc_free_expr (e2vtab); + } + size_in_bytes = size; + } else { /* Otherwise use the length in bytes of the rhs. */ @@ -7096,7 +7119,8 @@ gfc_add_expr_to_block (&block, tmp); } else if (init && (cm->attr.allocatable - || (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable))) + || (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable + && expr->ts.type != BT_CLASS))) { /* Take care about non-array allocatable components here. The alloc_* routine below is motivated by the alloc_scalar_allocatable_for_ Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (Revision 225927) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2015-07-17 Andre Vehreschild + + PR fortran/66035 + * gfortran.dg/structure_constructor_13.f03: New test. + 2015-07-17 Mikael Morin PR fortran/61831 Index: gcc/testsuite/gfortran.dg/structure_constructor_13.f03 =================================================================== --- gcc/testsuite/gfortran.dg/structure_constructor_13.f03 (Revision 0) +++ gcc/testsuite/gfortran.dg/structure_constructor_13.f03 (Arbeitskopie) @@ -0,0 +1,28 @@ +! { dg-do run } +! +! Contributed by Melven Roehrig-Zoellner +! PR fortran/66035 + +program test_pr66035 + type t + end type t + type w + class(t), allocatable :: c + end type w + + type(t) :: o + + call test(o) +contains + subroutine test(o) + class(t), intent(inout) :: o + type(w), dimension(:), allocatable :: list + + select type (o) + class is (t) + list = [w(o)] ! This caused an ICE + class default + call abort() + end select + end subroutine +end program --MP_/+V8VDZwbnFjV.ClkU8wlid8--