From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24150 invoked by alias); 30 Sep 2012 12:51:27 -0000 Received: (qmail 24111 invoked by uid 48); 30 Sep 2012 12:51:13 -0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/54618] [OOP] wrong-code with CLASS(...), INTENT(OUT) -- and OPTIONAL or ALLOCATABLE Date: Sun, 30 Sep 2012 12:51:00 -0000 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: dominiq at lps dot ens.fr 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: Status Last reconfirmed Ever Confirmed 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 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: 2012-09/txt/msg02447.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54618 Dominique d'Humieres changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-09-30 Ever Confirmed|0 |1 --- Comment #11 from Dominique d'Humieres 2012-09-30 12:51:11 UTC --- With the patch in comment #10, gfortran (otherwise clean r191847) miscompiles gfortran.dg/class_array_7.f03. If I replace the "if ... abort()" with prints, I get a is extended_type tmp is base_type a is extended_type a.out(83666) malloc: *** error for object 0x100200f80: pointer being freed was not allocated or [macbook] f90/bug% valgrind a.out ==96855== Memcheck, a memory error detector ==96855== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==96855== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==96855== Command: a.out ==96855== a is extended_type tmp is base_type ==96855== Invalid read of size 4 ==96855== at 0x100001782: __realloc_MOD_assign (class_array_7_db.f90:25) ==96855== by 0x100001685: __realloc_MOD_reallocate (class_array_7_db.f90:34) ==96855== by 0x100001A61: MAIN__ (class_array_7_db.f90:57) ==96855== by 0x100001BD5: main (class_array_7_db.f90:50) ==96855== Address 0x100442408 is 0 bytes after a block of size 40 alloc'd ==96855== at 0x100013679: malloc (vg_replace_malloc.c:266) ==96855== by 0x100001830: MAIN__ (class_array_7_db.f90:54) ==96855== by 0x100001BD5: main (class_array_7_db.f90:50) ==96855== a is extended_type ==96855== Invalid free() / delete / delete[] / realloc() ==96855== at 0x10001352D: free (vg_replace_malloc.c:430) ==96855== by 0x100001B9D: MAIN__ (class_array_7_db.f90:60) ==96855== by 0x100001BD5: main (class_array_7_db.f90:50) ==96855== Address 0x1004423e0 is 0 bytes inside a block of size 40 free'd ==96855== at 0x10001352D: free (vg_replace_malloc.c:430) ==96855== by 0x1000016BB: __realloc_MOD_reallocate (class_array_7_db.f90:35) ==96855== by 0x100001A61: MAIN__ (class_array_7_db.f90:57) ==96855== by 0x100001BD5: main (class_array_7_db.f90:50) ==96855== ==96855== ==96855== HEAP SUMMARY: ==96855== in use at exit: 168 bytes in 2 blocks ==96855== total heap usage: 25 allocs, 24 frees, 7,321 bytes allocated ==96855== ==96855== LEAK SUMMARY: ==96855== definitely lost: 80 bytes in 1 blocks ==96855== indirectly lost: 0 bytes in 0 blocks ==96855== possibly lost: 0 bytes in 0 blocks ==96855== still reachable: 0 bytes in 0 blocks ==96855== suppressed: 88 bytes in 1 blocks ==96855== Rerun with --leak-check=full to see details of leaked memory ==96855== ==96855== For counts of detected and suppressed errors, rerun with: -v ==96855== ERROR SUMMARY: 6 errors from 2 contexts (suppressed: 0 from 0) Otherwise the patch works as advertised.