* [Bug fortran/57456] [OOP] CLASS ALLOCATE with typespec: Too little memory allocated
2013-05-29 17:16 [Bug fortran/57456] New: [OOP] CLASS ALLOCATE with typespec: Too little memory allocated burnus at gcc dot gnu.org
@ 2013-05-29 17:17 ` burnus at gcc dot gnu.org
2013-05-29 17:59 ` burnus at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-05-29 17:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57456
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Note: It works if one uses a scalar instead of an array.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57456] [OOP] CLASS ALLOCATE with typespec: Too little memory allocated
2013-05-29 17:16 [Bug fortran/57456] New: [OOP] CLASS ALLOCATE with typespec: Too little memory allocated burnus at gcc dot gnu.org
2013-05-29 17:17 ` [Bug fortran/57456] " burnus at gcc dot gnu.org
@ 2013-05-29 17:59 ` burnus at gcc dot gnu.org
2013-06-27 21:35 ` [Bug fortran/57456] [OOP] CLASS + CHARACTER ALLOCATE with typespec: For arrays, the typespec is ignored dominiq at lps dot ens.fr
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-05-29 17:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57456
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
There is a similar problem for:
character(len=:), allocatable :: str(:)
allocate (character(len=5) :: str(5))
end
* * *
To solve this properly, one should put all the logic into gfc_trans_allocate -
and avoid duplicating it in gfc_array_init_size (which is called from
gfc_array_allocate, which is called from the mentioned gfc_trans_allocate).
Note: Also the evaluation of the type-spec length should be done only once for
allocate (character(len = f()) :: str(5), str2, str3, str4(10))
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57456] [OOP] CLASS + CHARACTER ALLOCATE with typespec: For arrays, the typespec is ignored
2013-05-29 17:16 [Bug fortran/57456] New: [OOP] CLASS ALLOCATE with typespec: Too little memory allocated burnus at gcc dot gnu.org
2013-05-29 17:17 ` [Bug fortran/57456] " burnus at gcc dot gnu.org
2013-05-29 17:59 ` burnus at gcc dot gnu.org
@ 2013-06-27 21:35 ` dominiq at lps dot ens.fr
2013-06-27 21:46 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-27 21:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57456
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2013-06-27
Ever confirmed|0 |1
--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Is not this PR supposed to have been fixed (partially) by revision 199528?
Revision 199528
Author: burnus
Date: Fri May 31 09:41:53 2013 UTC (3 weeks, 6 days ago)
Changed paths: 6
Log Message:
2013-05-31 Tobias Burnus <burnus@net-b.de>
PR fortran/57456
* trans-array.c (gfc_array_init_size): Use passed type spec,
when available.
(gfc_array_allocate): Pass typespec on.
* trans-array.h (gfc_array_allocate): Update prototype.
* trans-stmt.c (gfc_trans_allocate): Pass typespec on.
2013-05-31 Tobias Burnus <burnus@net-b.de>
PR fortran/57456
* gfortran.dg/class_array_17.f90: New.
Note that the problem in comment #2 is still there at revision 200486.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57456] [OOP] CLASS + CHARACTER ALLOCATE with typespec: For arrays, the typespec is ignored
2013-05-29 17:16 [Bug fortran/57456] New: [OOP] CLASS ALLOCATE with typespec: Too little memory allocated burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2013-06-27 21:35 ` [Bug fortran/57456] [OOP] CLASS + CHARACTER ALLOCATE with typespec: For arrays, the typespec is ignored dominiq at lps dot ens.fr
@ 2013-06-27 21:46 ` burnus at gcc dot gnu.org
2015-03-19 15:27 ` vehre at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-06-27 21:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57456
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #3)
> Is not this PR supposed to have been fixed (partially) by revision 199528?
Yes. The patch fixes the derived-type issue - but it doesn't solve the
CHARACTER issue. As written in comment 2, the proper way is use one common code
in gfc_trans_allocate, which calculates the byte size, and use it both for
scalars (directly in gfc_trans_allocate) and for arrays in gfc_array_allocate
-> gfc_array_init_size. (One also should evaluate the LEN= expression only
once.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57456] [OOP] CLASS + CHARACTER ALLOCATE with typespec: For arrays, the typespec is ignored
2013-05-29 17:16 [Bug fortran/57456] New: [OOP] CLASS ALLOCATE with typespec: Too little memory allocated burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2013-06-27 21:46 ` burnus at gcc dot gnu.org
@ 2015-03-19 15:27 ` vehre at gcc dot gnu.org
2015-03-24 10:38 ` vehre at gcc dot gnu.org
2015-04-23 12:58 ` vehre at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-03-19 15:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57456
vehre at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
--- Comment #5 from vehre at gcc dot gnu.org ---
Remain issue should be fixed with:
https://gcc.gnu.org/ml/fortran/2015-03/msg00074.html
https://gcc.gnu.org/ml/fortran/2015-03/msg00075.html
https://gcc.gnu.org/ml/fortran/2015-03/msg00085.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57456] [OOP] CLASS + CHARACTER ALLOCATE with typespec: For arrays, the typespec is ignored
2013-05-29 17:16 [Bug fortran/57456] New: [OOP] CLASS ALLOCATE with typespec: Too little memory allocated burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2015-03-19 15:27 ` vehre at gcc dot gnu.org
@ 2015-03-24 10:38 ` vehre at gcc dot gnu.org
2015-04-23 12:58 ` vehre at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-03-24 10:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57456
--- Comment #6 from vehre at gcc dot gnu.org ---
Author: vehre
Date: Tue Mar 24 10:28:48 2015
New Revision: 221621
URL: https://gcc.gnu.org/viewcvs?rev=221621&root=gcc&view=rev
Log:
gcc/fortran/ChangeLog
2015-03-24 Andre Vehreschild <vehre@gmx.de>
PR fortran/64787
PR fortran/57456
PR fortran/63230
* class.c (gfc_add_component_ref): Free no longer needed
ref-chains to prevent memory loss.
(find_intrinsic_vtab): For deferred length char arrays or
unlimited polymorphic objects, store the size in bytes of one
character in the size component of the vtab.
* gfortran.h: Added gfc_add_len_component () define.
* trans-array.c (gfc_trans_create_temp_array): Switched to new
function name for getting a class' vtab's field.
(build_class_array_ref): Likewise.
(gfc_array_init_size): Using the size information from allocate
more consequently now, i.e., the typespec of the entity to
allocate is no longer needed. This is to address the last open
comment in PR fortran/57456.
(gfc_array_allocate): Likewise.
(structure_alloc_comps): gfc_copy_class_to_class () needs to
know whether the class is unlimited polymorphic.
* trans-array.h: Changed interface of gfc_array_allocate () to
reflect the no longer needed typespec.
* trans-expr.c (gfc_find_and_cut_at_last_class_ref): New.
(gfc_reset_len): New.
(gfc_get_class_array_ref): Switch to new function name for
getting a class' vtab's field.
(gfc_copy_class_to_class): Added flag to know whether the class
to copy is unlimited polymorphic. Adding _len dependent code
then, which calls ->vptr->copy () with four arguments adding
the length information ->vptr->copy(from, to, from_len, to_cap).
(gfc_conv_procedure_call): Switch to new function name for
getting a class' vtab's field.
(alloc_scalar_allocatable_for_assignment): Use the string_length
as computed by gfc_conv_expr and not the statically backend_decl
which may be incorrect when ref-ing.
(gfc_trans_assignment_1): Use the string_length variable and
not the rse.string_length. The former has been computed more
generally.
* trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Switch to new
function name for getting a class' vtab's field.
(gfc_conv_intrinsic_storage_size): Likewise.
(gfc_conv_intrinsic_transfer): Likewise.
* trans-stmt.c (gfc_trans_allocate): Restructured to evaluate
source=expr3 only once before the loop over the objects to
allocate, when the objects are not arrays. Doing correct _len
initialization and calling of vptr->copy () fixing PR 64787.
(gfc_trans_deallocate): Reseting _len to 0, preventing future
errors.
* trans.c (gfc_build_array_ref): Switch to new function name
for getting a class' vtab's field.
(gfc_add_comp_finalizer_call): Likewise.
* trans.h: Define the prototypes for the gfc_class_vtab_*_get ()
and gfc_vptr_*_get () functions.
Added gfc_find_and_cut_at_last_class_ref () and
gfc_reset_len () routine prototype. Added flag to
gfc_copy_class_to_class () prototype to signal an unlimited
polymorphic entity to copy.
gcc/testsuite/ChangeLog
2015-03-24 Andre Vehreschild <vehre@gmx.de>
* gfortran.dg/allocate_alloc_opt_13.f90: Added tests for
source= and mold= expressions functionality.
* gfortran.dg/allocate_class_4.f90: New test.
* gfortran.dg/unlimited_polymorphic_20.f90: Added test whether
copying an unlimited polymorhpic object containing a char array
to another unlimited polymorphic object respects the _len
component.
* gfortran.dg/unlimited_polymorphic_22.f90: Extended to check
whether deferred length char array allocate works, unlimited
polymorphic object allocation from a string works and if
allocating an array of deferred length strings works.
* gfortran.dg/unlimited_polymorphic_24.f03: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/allocate_class_4.f90
trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_24.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/class.c
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-array.h
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-intrinsic.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/fortran/trans.c
trunk/gcc/fortran/trans.h
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/allocate_alloc_opt_13.f90
trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_20.f90
trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_22.f90
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/57456] [OOP] CLASS + CHARACTER ALLOCATE with typespec: For arrays, the typespec is ignored
2013-05-29 17:16 [Bug fortran/57456] New: [OOP] CLASS ALLOCATE with typespec: Too little memory allocated burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2015-03-24 10:38 ` vehre at gcc dot gnu.org
@ 2015-04-23 12:58 ` vehre at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-04-23 12:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57456
vehre at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from vehre at gcc dot gnu.org ---
Fixed with commit r221621.
^ permalink raw reply [flat|nested] 8+ messages in thread