From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21603 invoked by alias); 3 Aug 2011 07:24:11 -0000 Received: (qmail 21589 invoked by uid 22791); 3 Aug 2011 07:24:10 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Aug 2011 07:23:56 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/47674] gfortran.dg/realloc_on_assign_5.f03: Segfault at run time for deferred (allocatable) string length X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 03 Aug 2011 07:24:00 -0000 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: 2011-08/txt/msg00321.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47674 --- Comment #2 from Tobias Burnus 2011-08-03 07:23:18 UTC --- The problem seems to be that for strings, the dependency resolver does not trigger: as there are no strides, certain dependencies are already handled, but it fails if the LHS/RHS variables are the same and LHS is reallocated because of a different (shorter) string length. dependency.c's gfc_dep_resolver has: case REF_SUBSTRING: /* Substring overlaps are handled by the string assignment code if there is not an underlying dependency. */ return (fin_dep == GFC_DEP_OVERLAP) ? 1 : 0; which returns 0 for: string = string(1:2) ! Issue: Realloc without temporary trans-expr.c's alloc_scalar_allocatable_for_assignment handles scalars, where the value might bet wrong. A similar issue exists for arrays, though here there are provisions for adding temporaries. (Cf. also trans-array.c's gfc_alloc_allocatable_for_assignment.) I am not quite sure whether which if any part should be handled in the depenedency analysis and which in the assignment code. At least the scalar assignment code does not seem provide for temporaries at all. A related issue is PR 49954: ICE with concatenated array strings.