This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/46408] [OOP] Segfault when running gfortran.dg/class_allocate_6.f03
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 2 Jan 2011 19:24:08 +0000
- Subject: [Bug fortran/46408] [OOP] Segfault when running gfortran.dg/class_allocate_6.f03
- Auto-submitted: auto-generated
- References: <bug-46408-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46408
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
--- Comment #8 from janus at gcc dot gnu.org 2011-01-02 19:23:55 UTC ---
(In reply to comment #7)
> 2) Forget about freeing the old value of 'dst' (which is fine as long as we
> only call _copy on allocation, where dst is undefined; this is currently the
> case).
This is definitely the proper thing to do: We only need _copy for ALLOCATE with
SOURCE. And the best thing is, it's really easily done:
Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c (revision 168379)
+++ gcc/fortran/class.c (working copy)
@@ -548,7 +548,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
copy->formal->next->sym = dst;
/* Set up code. */
sub_ns->code = gfc_get_code ();
- sub_ns->code->op = EXEC_ASSIGN;
+ sub_ns->code->op = EXEC_INIT_ASSIGN;
sub_ns->code->expr1 = gfc_lval_expr_from_sym (dst);
sub_ns->code->expr2 = gfc_lval_expr_from_sym (src);
/* Set initializer. */
It took me a long while to see this, but in the end it's completely trivial.
I'll commit after regtesting.