From patchwork Tue Nov 30 17:03:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 73634 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]) by ozlabs.org (Postfix) with SMTP id ADF761007D2 for ; Wed, 1 Dec 2010 04:04:10 +1100 (EST) Received: (qmail 15479 invoked by alias); 30 Nov 2010 17:04:07 -0000 Received: (qmail 15453 invoked by uid 22791); 30 Nov 2010 17:04:05 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Nov 2010 17:03:59 +0000 Received: from [192.168.178.22] (port-92-204-29-144.dynamic.qsc.de [92.204.29.144]) by mx01.qsc.de (Postfix) with ESMTP id 623253D585; Tue, 30 Nov 2010 18:03:56 +0100 (CET) Message-ID: <4CF52E7B.3010204@net-b.de> Date: Tue, 30 Nov 2010 18:03:55 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101026 SUSE/3.1.6 Thunderbird/3.1.6 MIME-Version: 1.0 To: Paul Richard Thomas CC: gcc patches , fortran@gcc.gnu.org Subject: Fix gfortran.dg/realloc_on_assign_2.f03 (was: Re: [Patch, fortran] PR35810 - [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables) References: <20101129110851.GA5111@physik.fu-berlin.de> <20101129200852.GB20815@physik.fu-berlin.de> <4CF4F390.3000403@net-b.de> In-Reply-To: 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 On 11/30/2010 05:47 PM, Paul Richard Thomas wrote: >> And as "xwrkt =invima (...)" only sets one element, all other elements are >> undefined according to the Fortran standard. But, using SUM, one accesses >> all elements. > Absolutely right - that's the point, isn't it? > Thus, your patch is correct. Committed as Rev. 167305. And to answer my question: For the function result an new array temporary will be malloced - hence the wrong results. Thus, there is an abort with MALLOC_PERTURB_ and thus valgrind shows uninitialized variables. Tobias Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 167304) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2010-11-30 Tobias Burnus + + * gfortran.dg/realloc_on_assign_2.f03 (invima): Assign + a value to all array elements. + 2010-11-30 Richard Guenther PR tree-optimization/46722 Index: gcc/testsuite/gfortran.dg/realloc_on_assign_2.f03 =================================================================== --- gcc/testsuite/gfortran.dg/realloc_on_assign_2.f03 (revision 167304) +++ gcc/testsuite/gfortran.dg/realloc_on_assign_2.f03 (working copy) @@ -114,6 +114,7 @@ real, dimension (1:m,1:m) :: invima real, dimension (1:m,1:m), intent (in) :: a integer, intent (in) :: j, k + invima = 0.0 invima (j, j) = 1.0 / (1.0 - a (j, j)) end function invima subroutine test6