From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29483 invoked by alias); 7 Jul 2007 09:29:24 -0000 Received: (qmail 29459 invoked by uid 48); 7 Jul 2007 09:29:15 -0000 Date: Sat, 07 Jul 2007 09:29:00 -0000 Subject: [Bug fortran/32665] New: allocatable array on lhs deleted while still in use on rhs X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dfranke 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: 2007-07/txt/msg00819.txt.bz2 While experimenting with testcases from PR31320, I hit this: $> cat alloc.f90 TYPE :: x INTEGER, ALLOCATABLE :: a(:) END TYPE TYPE(x) :: a a = x((/ 1, 2, 3 /)) a = x((/ a%a, 4 /)) end $> gfortran-svn -g -Wall -fdump-tree-original allocatable.f90 && ./a.out Segmentation fault $> valgrind --tool=memcheck --leak-check=full ./a.out [...] ==2287== Invalid read of size 4 ==2287== at 0x804895F: MAIN__ (allocatable.f90:8) ==2287== by 0x8048C78: main (fmain.c:22) ==2287== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==2287== ==2287== Process terminating with default action of signal 11 (SIGSEGV) ==2287== Access not within mapped region at address 0x0 ==2287== at 0x804895F: MAIN__ (allocatable.f90:8) ==2287== by 0x8048C78: main (fmain.c:22) >>From trre-dump: [...] _gfortran_deallocate (a.a.data, &D.1050); a.a.data = 0B; [...] D.1029 = (int4[0:] *) a.a.data; [...] while (1) { if (S.6 > a.a.dim[0].ubound) goto L.1; (*(int4[0:] *) atmp.4.data)[offset.5] = (*D.1029)[S.6 * D.1034 + D.1030]; offset.5 = offset.5 + 1; S.6 = S.6 + 1; } L.1:; $> gcc version 4.3.0 20070705 (experimental) -- Summary: allocatable array on lhs deleted while still in use on rhs Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dfranke at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32665