public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110618] New: Dependency between arguments when one is allocatable array whose dummy is intent(out)
@ 2023-07-10 18:26 mikael at gcc dot gnu.org
2023-07-10 20:53 ` [Bug fortran/110618] " mikael at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: mikael at gcc dot gnu.org @ 2023-07-10 18:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110618
Bug ID: 110618
Summary: Dependency between arguments when one is allocatable
array whose dummy is intent(out)
Product: gcc
Version: 11.4.1
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mikael at gcc dot gnu.org
CC: abensonca at gcc dot gnu.org, anlauf at gcc dot gnu.org,
burnus at gcc dot gnu.org, kargl at gcc dot gnu.org,
vladimir.fuka at gmail dot com
Depends on: 92178
Blocks: 87142
Target Milestone: ---
+++ This bug was initially created as a clone of Bug #92178 +++
PR 92178 has several cases of dependency between arguments when one of them is
deallocated before the call in the process of argument association.
Here is another example which I don't want to handle there (and which I don't
know how to fix).
program p
implicit none
type t
integer :: i
end type t
type u
class(t), allocatable :: ta(:)
end type u
type(u), allocatable :: c(:)
class(t), allocatable :: d(:)
allocate(c, source = [u([t(1), t(3)]), u([t(4), t(9)])])
allocate(d, source = [t(1), t(5)])
call bar ( &
allocated(c(d(1)%i)%ta), &
d, &
c(d(1)%i)%ta, &
allocated (c(d(1)%i)%ta) &
)
if (allocated (c(1)%ta)) stop 11
if (.not. allocated (c(2)%ta)) stop 12
contains
subroutine bar (alloc, x, y, alloc2)
logical :: alloc, alloc2
class(t), allocatable, intent(out) :: x(:)
class(t), allocatable, intent(out) :: y(:)
if (allocated (x)) stop 1
if (.not. alloc) stop 2
if (.not. alloc2) stop 3
end subroutine bar
end
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87142
[Bug 87142] Aliasing issue with overloaded assignment and allocatable
components
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92178
[Bug 92178] Segmentation fault after passing allocatable array as intent(out)
and its element as value into the same subroutine
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/110618] Dependency between arguments when one is allocatable array whose dummy is intent(out)
2023-07-10 18:26 [Bug fortran/110618] New: Dependency between arguments when one is allocatable array whose dummy is intent(out) mikael at gcc dot gnu.org
@ 2023-07-10 20:53 ` mikael at gcc dot gnu.org
2023-07-13 19:29 ` mikael at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mikael at gcc dot gnu.org @ 2023-07-10 20:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110618
--- Comment #1 from Mikael Morin <mikael at gcc dot gnu.org> ---
Created attachment 55517
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55517&action=edit
Draft patch
This seems to work for this case, but I'm not sure how reliable it is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/110618] Dependency between arguments when one is allocatable array whose dummy is intent(out)
2023-07-10 18:26 [Bug fortran/110618] New: Dependency between arguments when one is allocatable array whose dummy is intent(out) mikael at gcc dot gnu.org
2023-07-10 20:53 ` [Bug fortran/110618] " mikael at gcc dot gnu.org
@ 2023-07-13 19:29 ` mikael at gcc dot gnu.org
2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mikael at gcc dot gnu.org @ 2023-07-13 19:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110618
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-07-13
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |mikael at gcc dot gnu.org
--- Comment #2 from Mikael Morin <mikael at gcc dot gnu.org> ---
Patches submitted:
https://gcc.gnu.org/pipermail/fortran/2023-July/059596.html
https://gcc.gnu.org/pipermail/gcc-patches/2023-July/624384.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/110618] Dependency between arguments when one is allocatable array whose dummy is intent(out)
2023-07-10 18:26 [Bug fortran/110618] New: Dependency between arguments when one is allocatable array whose dummy is intent(out) mikael at gcc dot gnu.org
2023-07-10 20:53 ` [Bug fortran/110618] " mikael at gcc dot gnu.org
2023-07-13 19:29 ` mikael at gcc dot gnu.org
@ 2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
2023-07-17 17:46 ` mikael at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-17 12:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110618
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Mikael Morin <mikael@gcc.gnu.org>:
https://gcc.gnu.org/g:1a46400e5ac0f21eead74b10752f69ebc7a8be27
commit r14-2579-g1a46400e5ac0f21eead74b10752f69ebc7a8be27
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Mon Jul 17 14:14:18 2023 +0200
fortran: Use pre-evaluated class container if available [PR110618]
Add the possibility to provide a pre-evaluated class container argument
to gfc_add_finalizer to avoid repeatedly evaluating data reference
expressions in the generated code.
PR fortran/110618
gcc/fortran/ChangeLog:
* trans.h (gfc_add_finalizer_call): Add class container argument.
* trans.cc (gfc_add_finalizer_call): Ditto. Pass down new
argument to get_final_proc_ref, get_elem_size, get_var_desc,
and get_vptr.
(get_elem_size): Add class container argument.
Use provided class container if it's available.
(get_var_descr): Same.
(get_vptr): Same.
(get_final_proc_ref): Same. Add boolean telling the class
container argument is used. Set it. Don't try to use
final_wrapper if class container argument was used.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/110618] Dependency between arguments when one is allocatable array whose dummy is intent(out)
2023-07-10 18:26 [Bug fortran/110618] New: Dependency between arguments when one is allocatable array whose dummy is intent(out) mikael at gcc dot gnu.org
` (2 preceding siblings ...)
2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
@ 2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
2023-07-17 17:46 ` mikael at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-17 12:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110618
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Mikael Morin <mikael@gcc.gnu.org>:
https://gcc.gnu.org/g:e21e13e2525a042a0aabfbcb4ebf4f08609078c7
commit r14-2580-ge21e13e2525a042a0aabfbcb4ebf4f08609078c7
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Mon Jul 17 14:14:22 2023 +0200
fortran: Pass pre-calculated class container argument [pr110618]
Pass already evaluated class container argument from
gfc_conv_procedure_call down to gfc_add_finalizer_call through
gfc_deallocate_scalar_with_status and gfc_deallocate_with_status,
to avoid repeatedly evaluating the same data reference expressions
in the generated code.
PR fortran/110618
gcc/fortran/ChangeLog:
* trans.h (gfc_deallocate_with_status): Add class container
argument.
(gfc_deallocate_scalar_with_status): Ditto.
* trans.cc (gfc_deallocate_with_status): Add class container
argument and pass it down to gfc_add_finalize_call.
(gfc_deallocate_scalar_with_status): Same.
* trans-array.cc (structure_alloc_comps): Update caller.
* trans-stmt.cc (gfc_trans_deallocate): Ditto.
* trans-expr.cc (gfc_conv_procedure_call): Ditto. Pass
pre-evaluated class container argument if it's available.
gcc/testsuite/ChangeLog:
* gfortran.dg/intent_out_22.f90: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/110618] Dependency between arguments when one is allocatable array whose dummy is intent(out)
2023-07-10 18:26 [Bug fortran/110618] New: Dependency between arguments when one is allocatable array whose dummy is intent(out) mikael at gcc dot gnu.org
` (3 preceding siblings ...)
2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
@ 2023-07-17 17:46 ` mikael at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: mikael at gcc dot gnu.org @ 2023-07-17 17:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110618
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Mikael Morin <mikael at gcc dot gnu.org> ---
Fixed for 14.0.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-07-17 17:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10 18:26 [Bug fortran/110618] New: Dependency between arguments when one is allocatable array whose dummy is intent(out) mikael at gcc dot gnu.org
2023-07-10 20:53 ` [Bug fortran/110618] " mikael at gcc dot gnu.org
2023-07-13 19:29 ` mikael at gcc dot gnu.org
2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
2023-07-17 12:16 ` cvs-commit at gcc dot gnu.org
2023-07-17 17:46 ` mikael at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).