Hello,
After a lot (a LOT) of work, I've come up with this test case. The test case
*appears* to run fine, but valgrind shows something is amiss, and in the full
application (much more complex) there follow multiple segfaults. I did not find
(so far) a way to have a test case both small and exibiting the error out of
valgrind, hope you'll pardon me. 
The error: the ALLOCATABLE components of the ATX%A variable are detected as
ALLOCATED, and seemingly are printed OK, but VALGRIND says they were already
freed.

===============================================================================
[sfili...@donald bug23]$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gnu46/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/local/gnu46
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.6.0 20100830 (experimental) (GCC) 
[sfili...@donald bug23]$ gfortran -ggdb  -o bug23 bug23.f03
[sfili...@donald bug23]$ ./bug23
 New version 
 Allocation status:  T T T
           0           0           4           5
           0           0           2           3           0           0       
   0           0           0           0           0           0
   0.0000000000000000        1.0000000000000000        2.0000000000000000      
 3.0000000000000000        0.0000000000000000        0.0000000000000000       
0.0000000000000000        0.0000000000000000        0.0000000000000000       
0.0000000000000000        0.0000000000000000        0.0000000000000000     
[sfili...@donald bug23]$ valgrind ./bug23
==6940== Memcheck, a memory error detector
==6940== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==6940== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==6940== Command: ./bug23
==6940== 
 New version 
 Allocation status:  T T T
==6940== Invalid read of size 4
==6940==    at 0x4CC19B8: extract_int (write.c:450)
==6940==    by 0x4CC27B1: write_integer (write.c:1260)
==6940==    by 0x4CC5BDE: _gfortrani_list_formatted_write (write.c:1552)
==6940==    by 0x4CBACA7: _gfortran_transfer_array (transfer.c:2000)
==6940==    by 0x401834: MAIN__ (bug23.f03:308)
==6940==    by 0x40197A: main (bug23.f03:284)
==6940==  Address 0x5141450 is 0 bytes inside a block of size 16 free'd
==6940==    at 0x4A04D72: free (vg_replace_malloc.c:325)
==6940==    by 0x4CCB5A8: _gfortran_move_alloc (move_alloc.c:41)
==6940==    by 0x400B90: __psb_d_csr_mat_mod_MOD_psb_d_mv_csr_from_fmt
(bug23.f03:238)
==6940==    by 0x401449: __psb_d_mat_mod_MOD_psb_d_mv_from (bug23.f03:277)
==6940==    by 0x4016C6: MAIN__ (bug23.f03:302)
==6940==    by 0x40197A: main (bug23.f03:284)
==6940== 
           1           3           4           5
           1           1           2           3           0           0       
   0           0           0           0           0           0
==6940== Invalid read of size 8
==6940==    at 0x4CC3795: write_float (write_float.def:1050)
==6940==    by 0x4CC508C: _gfortrani_write_real (write.c:1470)
==6940==    by 0x4CC5BAE: _gfortrani_list_formatted_write (write.c:1561)
==6940==    by 0x4CBACA7: _gfortran_transfer_array (transfer.c:2000)
==6940==    by 0x401904: MAIN__ (bug23.f03:310)
==6940==    by 0x40197A: main (bug23.f03:284)
==6940==  Address 0x5141510 is 0 bytes inside a block of size 96 free'd
==6940==    at 0x4A04D72: free (vg_replace_malloc.c:325)
==6940==    by 0x4CCB5A8: _gfortran_move_alloc (move_alloc.c:41)
==6940==    by 0x400BDC: __psb_d_csr_mat_mod_MOD_psb_d_mv_csr_from_fmt
(bug23.f03:240)
==6940==    by 0x401449: __psb_d_mat_mod_MOD_psb_d_mv_from (bug23.f03:277)
==6940==    by 0x4016C6: MAIN__ (bug23.f03:302)
==6940==    by 0x40197A: main (bug23.f03:284)
==6940== 
   1.0000000000000000        1.0000000000000000        2.0000000000000000      
 3.0000000000000000        0.0000000000000000        0.0000000000000000       
0.0000000000000000        0.0000000000000000        0.0000000000000000       
0.0000000000000000        0.0000000000000000        0.0000000000000000     
==6940== 
==6940== HEAP SUMMARY:
==6940==     in use at exit: 0 bytes in 0 blocks
==6940==   total heap usage: 33 allocs, 33 frees, 4,938 bytes allocated
==6940== 
==6940== All heap blocks were freed -- no leaks are possible
==6940== 
==6940== For counts of detected and suppressed errors, rerun with: -v
==6940== ERROR SUMMARY: 28 errors from 2 contexts (suppressed: 6 from 6)


-- 
           Summary: [OOP] Inconsistent status of ALLOCATABLE components
                    inside CLASS variables.
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sfilippone at uniroma2 dot it
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45451

Reply via email to