http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54618
Dominique d'Humieres <dominiq at lps dot ens.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-09-30 Ever Confirmed|0 |1 --- Comment #11 from Dominique d'Humieres <dominiq at lps dot ens.fr> 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.