From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20287 invoked by alias); 16 Dec 2010 09:10:43 -0000 Received: (qmail 20243 invoked by uid 22791); 16 Dec 2010 09:10:40 -0000 X-SWARE-Spam-Status: No, hits=-2.8 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; Thu, 16 Dec 2010 09:10:35 +0000 From: "m.a.hulsen at tue dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/46978] New: TRANSPOSE corrupts structure and memory X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: m.a.hulsen at tue dot nl 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: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Thu, 16 Dec 2010 09:10: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: 2010-12/txt/msg01873.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D46978 Summary: TRANSPOSE corrupts structure and memory Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: m.a.hulsen@tue.nl Created attachment 22783 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=3D22783 the source files and Makefile I found a serious issue with the TRANSPOSE intrinsic function, possibly when combined with the reshape intrinsic. I tried to create a small sample program, but I was unsuccessful. Therefore I decided to start from the failing big program and made it as sm= all as possible but still showing the issue. It turned out to be very tricky and there are still 4275 lines of code left. However, all of the code in mods.f90 is necessary to build the structure me= sh and is fine. The problem appears at a single line in the small main program after building the mesh structure. The corruption is related to the statement: mesh%objects(1)%coor =3D transpose ( reshape ( a, (/2,nno/) ) ) at line 113 in the file mainprog.f90, which corrupt other parts of the structure mesh. In particular the parts mesh%blocks(2)%elements and mesh$blocks(3)%elements are overwritten. For example: mesh%blocks(3)%elements before: 1 1 1 1 1 21 22 23 24 25 mesh%blocks(3)%elements after: 1 1 1 1 1 21 22 23 0 1072693248 If I remove the stop statement at line 124, I also get a message: *** glibc detected *** mainprog: double free or corruption (!prev): 0x00000000008fe440 *** with a corresponding backtrace. If I uncomment lines 5, 6 and 7 in mainprog.f90, and basically replacing the intrinsic transpose with my own version, the problem is gone. Note, that it runs fine with gfortran from 6th June 2010 (from Tobias Burnu= s=E2=80=99 homepage), g95, ifort, Lahey/Fujitsu and nagfor.