[RFC] Polymorphic deep copy (aka PR46174)
Janus Weil
janus@gcc.gnu.org
Wed Nov 3 00:32:00 GMT 2010
Hi all,
PR 46174 brought up the necessity of doing a deep copy of polymorphic
variables (with allocatable components). Tobias pointed out that the
best (only?) way to accomplish this would be to add a new procedure
pointer component (named '$copy') to the vtab, which would point to a
copying routine for the corresponding type. Polymorphic deallocation
could be handled analogously.
Attached is a draft patch which does just that: It adds two new PPCs
to the vtab ($copy and $free) and sets up the corresponding routines.
Looking at the dump for a test case indicates that this seems to work
quite nicely already. What does not work yet is the calling of these
routines (which means there is something wrong in the hunk in
trans-decl.c, which was just a quick try - I'll improve this soon).
Two questions:
1) Am I technically on the right track with this patch? Any comments?
2) Is this patch appropriate for whatever stage of development GCC is
currently in? [The website still shows "stage 1", while the last
status report said stage 1 would end at the end of October.]
Regarding the general status of OOP: Polymorphic arrays will
apparently not make it into the 4.6 release, since I was kept busy
with tons of bugfixing. So the aim now is at least to have polymorphic
scalars as feature-complete and bug-free as possible (to which this
patch is an important contribution, even more so because it is one of
those nasty wrong-code bugs which are not caught at compile-time).
Cheers,
Janus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr46174.diff
Type: application/octet-stream
Size: 7356 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20101103/cd9440e9/attachment.obj>
More information about the Fortran
mailing list