From patchwork Mon Mar 24 23:59:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 333198 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 06C8414008C for ; Tue, 25 Mar 2014 11:00:03 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=lSF3mJD6I5MyX+gPOQO5Anx11CvMahT47U7BM8EFc74b1S i/ZDDfgDxEVX1hpxe4qwl1InTKooMuN+IuD4NDBmjTzbdNsPli11U3SEOetN7LoZ UYVKbwPkOsJfRwE2B86THmhZb1LV8E6cW/N0r33RCjekCZCAdQ3BSVM5dmHH4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=YK2/hBFjQfrGcs7d5oUqXRK8YaY=; b=lOx8H0spK60vTpsAzyKY kjhb2han+xf+G7DGvO8IKgDtwHuHUxQdfiicVx05iZcQ53AM/nEiLGdRDbvWMl8X up9h+zl5QQ24sSMYyo0nqS1AKtgGuSamzwWHktSQARebG3r1ym3ipJMyp4sDkCad CNcKCktvs0L/vSiPDquug4k= Received: (qmail 926 invoked by alias); 24 Mar 2014 23:59:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 880 invoked by uid 89); 24 Mar 2014 23:59:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx01.qsc.de Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 24 Mar 2014 23:59:32 +0000 Received: from tux.net-b.de (port-92-194-244-210.dynamic.qsc.de [92.194.244.210]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPSA id 4DD613D06E; Tue, 25 Mar 2014 00:59:29 +0100 (CET) Message-ID: <5330C6E0.4040103@net-b.de> Date: Tue, 25 Mar 2014 00:59:28 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: gcc-patches , gfortran Subject: [Patch, Fortran] PR60576 Fix out-of-bounds problem This patch fixes part of the problems of the PR. The problem is that one assigns an array descriptor to an assumed-rank array descriptor. The latter has for BT_CLASS the size of max_dim (reason: we have first the "data" array and than "vtab"). With "true", one takes the TREE_TYPE from the LHS (i.e. the assumed-rank variable) and as the type determines how many bytes the range assignment copies, one reads max_dimension elements from the RHS array - which can be too much. Testcase: Already in the testsuite, even if it only fails under special conditions. Build and regtested on x86-64-gnu-linux. OK for the trunk and 4.8? Tobias PS: I haven't investigated the issues Jakub is seeing. With valgrind, they do not pop up and my attempt to build with all checking enabled, failed with configure or compile errors. 2014-03-25 Mikael Morin Tobias Burnus PR fortran/ * trans-expr.c (gfc_conv_derived_to_class): Avoid generation of out-of-bounds range expr. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index f5350bb..30931a3 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -424,7 +426,11 @@ gfc_conv_derived_to_class (gfc_se *parmse, gfc_expr *e, gfc_conv_expr_descriptor (parmse, e); if (e->rank != class_ts.u.derived->components->as->rank) - class_array_data_assign (&block, ctree, parmse->expr, true); + { + gcc_assert (class_ts.u.derived->components->as->type + == AS_ASSUMED_RANK); + class_array_data_assign (&block, ctree, parmse->expr, false); + } else { if (gfc_expr_attr (e).codimension)