------- Comment #2 from burnus at gcc dot gnu dot org  2010-09-03 12:12 -------
(In reply to comment #1)
> Here is a patch to accept the type declaration in comment #0:

Well, you at least need to use gfc_notify_std(GFC_STD_F2008, ... And one should
make sure that the allocation/clean up works as expected.

 * * *

As follow up to the initial implementation, one should implement at some point
the following, which does not do a deep copy but simply appends the old data.
(Example from the mentioned article.)

type entry
  real :: value
  integer :: index
  type(entry), allocatable :: next
end type entry

type (entry), allocatable :: top
top = entry ( new_value, new_index, top )

(The last line assume reallocate on assignment; I think it already works for
derived types with structure constructor; I know that it does not yet work for
intrinsic types - not does it work on other assignment than structure
constructors.)

The classical way to append a new item is the following, which should avoid a
deep copy (check!):

  type (entry), allocatable :: top, temp
  temp = entry ( new_value, new_index, temp )
  call move_alloc(top,temp%next)
  call move_alloc(temp,top)


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |domob at gcc dot gnu dot
                   |                            |org, burnus at gcc dot gnu
                   |                            |dot org


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

Reply via email to