This is the mail archive of the mailing list for the GNU Fortran project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Polymorphic deep copy (aka PR46174)

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).


Attachment: pr46174.diff
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]