------- Comment #13 from dominiq at lps dot ens dot fr 2010-02-28 11:20 -------
> Thanks for testing! In trans-array.c's gfc_trans_deferred_array, my current
> version has
>
> - if (sym->value)
> + if (sym->value == NULL || !has_default_initializer (sym->ts.u.derived))
> ^^^^^^^^^^^^^^^^^^^^^^
> This part is new
>
> Hopefully, that is all what is needed.
Apparently, yes (all my tests pass now).
Following pr43205, I have found an other issue. I don't see this pr with
patched trunk, but with all my other builds. So I have slightly changed the
test to
subroutine testproblem
integer nsub_sta(1146, 2000), nsub_sto(1146, 2000)
write (*,*) nsub_sta(1000,1000)
write (*,*) nsub_sto(1000,1000)
return
end
call testproblem
end
With revision 156618 I get
[macbook] f90/bug% time gfc_c -fno-automatic -finit-integer=-100 pr43205_db.f90
4.575u 0.463s 0:06.59 76.3% 0+0k 1+25io 0pf+0w
[macbook] f90/bug% a.out
-100
-100
but with my patched trunk I get
[macbook] f90/bug% time gfc -fno-automatic -finit-integer=-100 pr43205_db.f90
0.019u 0.022s 0:00.04 75.0% 0+0k 0+0io 0pf+0w
[macbook] f90/bug% a.out
0
0
[macbook] f90/bug% time gfc -finit-integer=-100 pr43205_db.f90
0.022u 0.022s 0:00.05 80.0% 0+0k 0+8io 0pf+0w
[macbook] f90/bug% a.out
-100
-100
So the patch breaks -finit-integer when used with -fno-automatic.
> Still, the patch needs to be audited - I wouldn't be surprised
> if some "free" were missing, leading to memory leakage in the generated code.
> /* Subroutine of gfc_trans_assignment that actually scalarizes the
> - assignment. EXPR1 is the destination/LHS and EXPR2 is the source/RHS. */
> + assignment. EXPR1 is the destination/LHS and EXPR2 is the source/RHS.
> + init_flag indicates initialization expressions, no_free that no
^^^^^^^
> + deallocate prior assignment is needed (if in doubt, set true). */
>
> static tree
> -gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag)
> +gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
> + bool dealloc)
^^^^^^^
It seems that no_free has been changed to dealloc. My knowledge of gfortran is
too bad to allow me to do any audit beyond this point!-(
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43178