From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25060 invoked by alias); 24 Oct 2010 10:04:32 -0000 Received: (qmail 25049 invoked by uid 22791); 24 Oct 2010 10:04:30 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,MISSING_MID 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; Sun, 24 Oct 2010 10:04:26 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/43018] alloc_comp_scalar_1.f90: Valgrind Invalid read of size 8 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: 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: Sun, 24 Oct 2010 10:04: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-10/txt/msg02010.txt.bz2 Message-ID: <20101024100400.LgqIY9uG-10ctZaW1CDnlGoW7MsVo3zKB9JwRgnYIWw@z> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43018 --- Comment #5 from Tobias Burnus 2010-10-24 10:04:19 UTC --- Actually, it does not have anything to do with PACK but rather with the assignment -- which implicitly also happens if one uses print *, pack(a2,[.true.]) The assignment works as follows: a) Free the pointer target of a1(1:1)%entry b) Pack: a1 = a2 ! struct a1 is OK, but a1%entry points to b1%entry c) allocate(tmp), allocate(tmp%entry), memcopy(tmp%entry = a1%entry) d) a1 = tmp ! i.e. a1%entry now points to tmp%entry e) free(tmp) ! but not free(tmp%entry)