------- Comment #4 from janus at gcc dot gnu dot org 2010-08-30 20:48 ------- Ok, I could reduce this quite a bit:
program bug23 implicit none type :: psb_base_sparse_mat integer, allocatable :: irp(:) end type psb_base_sparse_mat class(psb_base_sparse_mat), allocatable :: a type(psb_base_sparse_mat) :: acsr allocate(acsr%irp(4)) acsr%irp(1:4) = (/1,3,4,5/) write(*,*) acsr%irp(:) allocate(a,source=acsr) write(*,*) a%irp(:) call move_alloc(acsr%irp, a%irp) write(*,*) a%irp(:) end program bug23 Executing gives: 1 3 4 5 1 3 4 5 0 0 4 5 The last line here should be the same as the first two. Changing the CLASS variable into a TYPE makes it work. Running through valgrind shows: ==11502== Command: ./a.out ==11502== 1 3 4 5 1 3 4 5 ==11502== Invalid read of size 4 ==11502== at 0x4EE59B8: extract_int (write.c:450) ==11502== by 0x4EE67B1: write_integer (write.c:1260) ==11502== by 0x4EE9BDE: _gfortrani_list_formatted_write (write.c:1552) ==11502== by 0x4EDECA7: _gfortran_transfer_array (transfer.c:2000) ==11502== by 0x400B07: MAIN__ (in /home/jweil/GSoC/PRs/45451/a.out) ==11502== by 0x400BA8: main (in /home/jweil/GSoC/PRs/45451/a.out) ==11502== Address 0x5934360 is 0 bytes inside a block of size 16 free'd ==11502== at 0x4C280BD: free (vg_replace_malloc.c:366) ==11502== by 0x4EEF5A8: _gfortran_move_alloc (move_alloc.c:41) ==11502== by 0x400AAC: MAIN__ (in /home/jweil/GSoC/PRs/45451/a.out) ==11502== by 0x400BA8: main (in /home/jweil/GSoC/PRs/45451/a.out) ==11502== 1 3 4 5 ==11502== ==11502== HEAP SUMMARY: ==11502== in use at exit: 0 bytes in 0 blocks ==11502== total heap usage: 18 allocs, 18 frees, 3,844 bytes allocated ==11502== ==11502== All heap blocks were freed -- no leaks are possible ==11502== ==11502== For counts of detected and suppressed errors, rerun with: -v ==11502== ERROR SUMMARY: 4 errors from 1 contexts (suppressed: 4 from 4) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45451