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



Salvatore Filippone <sfilippone at uniroma2 dot it> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |sfilippone at uniroma2 dot

                   |                            |it



--- Comment #8 from Salvatore Filippone <sfilippone at uniroma2 dot it> 
2012-10-08 16:22:42 UTC ---

Hello,

I have a different problem that is definitely related to this area, but may or

may not be the same. 

I have (as usual :) a complex nesting of polymorphic derived types, and I have

a need to handle reallocation and re-population of a vector of such containers. 

The type hierarchy is something like this



  type mld_d_base_solver_type

  end type 



  type  mld_d_base_smoother_type

    class(mld_d_base_solver_type), allocatable :: sv

  end 



  type mld_d_onelev_type

    class(mld_d_base_smoother_type), allocatable :: sm

  end type 



  type, extends(psb_dprec_type)         :: mld_dprec_type

    type(mld_d_onelev_type), allocatable :: precv(:) 

  end type 





Consider the following snippet of code:

  --------------------

    deallocate(p%precv,stat=info)



    if (info == 0) allocate(p%precv(newsz),stat=info) 

    if (info /= 0) then 

      info = -1

      return

    end if



    do i=1, newsz

      if (info == 0) then 

        if (i ==1) then 

          allocate(p%precv(i)%sm,source=base_sm,stat=info) 

        else if (i < newsz) then 

          allocate(p%precv(i)%sm,source=med_sm,stat=info) 

        else

          allocate(p%precv(i)%sm,source=coarse_sm,stat=info) 

        end if

      end if

      if (info /= 0) then 

        info = -1

        return

      end if

      write(0,*) 'Copy back at level',i

      do k=1,i

        write(0,*) '   level',k

        call p%precv(k)%sm%sv%descr(info,iout=0)

        if (info /= 0) return

      end do







    end do

------------------------------------------------

You would expect the allocate with source at I=4 to leave untouched the

elements of p%precv(1:3), and yet this is the output I get with 4.7.2:

------------------------------------------------



 Copy back at level           1

    level           1

   TLU: test a new solver kind



 Copy back at level           2

    level           1

   TLU: test a new solver kind



    level           2

   TLU: test a new solver kind



 Copy back at level           3

    level           1

   TLU: test a new solver kind



    level           2

   TLU: test a new solver kind



    level           3

   TLU: test a new solver kind



 Copy back at level           4

    level           1

   Incomplete factorization solver: ILU(n)         

   Fill level:           0

    level           2

   Incomplete factorization solver: ILU(n)         

   Fill level:           0

    level           3

   Incomplete factorization solver: ILU(n)         

   Fill level:           0

    level           4

   Incomplete factorization solver: ILU(n)         

   Fill level:           0

 Intermediate at level 1

   Incomplete factorization solver: ILU(n)         

   Fill level:           0

-----------------------------------------------------------------

This clearly does not make sense. 

I can send Janus the full code to reproduce the error. 

Does it seem related? 

Thanks

Salvatore

Reply via email to