* [PATCH] PR fortran/99169 - [9/10/11 Regression] Segfault when passing allocatable scalar into intent(out) dummy argument
@ 2021-02-19 21:16 Harald Anlauf
2021-02-20 21:02 ` Tobias Burnus
0 siblings, 1 reply; 2+ messages in thread
From: Harald Anlauf @ 2021-02-19 21:16 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
Dear all,
we should not clobber the pointer in case of an allocatable scalar being
an intent(out) dummy argument to a procedure.
Regtested on x86_64-pc-linux-gnu.
OK for master? Since this is a regression, also for backports to 10/9?
Thanks,
Harald
PR fortran/99169 - Do not clobber allocatable intent(out) dummy argument
gcc/fortran/ChangeLog:
* trans-expr.c (gfc_conv_procedure_call): Do not add clobber to
allocatable intent(out) argument.
gcc/testsuite/ChangeLog:
* gfortran.dg/intent_optimize_3.f90: New test.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr99169.patch --]
[-- Type: text/x-patch, Size: 1121 bytes --]
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 103cb31c664..cab58cd1bba 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6077,6 +6079,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
&& !fsym->attr.allocatable && !fsym->attr.pointer
&& !e->symtree->n.sym->attr.dimension
&& !e->symtree->n.sym->attr.pointer
+ && !e->symtree->n.sym->attr.allocatable
/* See PR 41453. */
&& !e->symtree->n.sym->attr.dummy
/* FIXME - PR 87395 and PR 41453 */
diff --git a/gcc/testsuite/gfortran.dg/intent_optimize_3.f90 b/gcc/testsuite/gfortran.dg/intent_optimize_3.f90
new file mode 100644
index 00000000000..6ecd722da76
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/intent_optimize_3.f90
@@ -0,0 +1,16 @@
+! { dg-do run }
+! { dg-options "-O2" }
+! PR99169 - Segfault passing allocatable scalar into intent(out) dummy argument
+
+program p
+ implicit none
+ integer, allocatable :: i
+ allocate (i)
+ call set (i)
+ if (i /= 5) stop 1
+contains
+ subroutine set (i)
+ integer, intent(out) :: i
+ i = 5
+ end subroutine set
+end program p
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PR fortran/99169 - [9/10/11 Regression] Segfault when passing allocatable scalar into intent(out) dummy argument
2021-02-19 21:16 [PATCH] PR fortran/99169 - [9/10/11 Regression] Segfault when passing allocatable scalar into intent(out) dummy argument Harald Anlauf
@ 2021-02-20 21:02 ` Tobias Burnus
0 siblings, 0 replies; 2+ messages in thread
From: Tobias Burnus @ 2021-02-20 21:02 UTC (permalink / raw)
To: Harald Anlauf, fortran, gcc-patches
Dear Harald,
On 19.02.21 22:16, Harald Anlauf via Fortran wrote:
> we should not clobber the pointer in case of an allocatable scalar being
> an intent(out) dummy argument to a procedure.
>
> Regtested on x86_64-pc-linux-gnu.
> OK for master? Since this is a regression, also for backports to 10/9?
OK to both master and to backporting.
Thanks for the patch!
Tobias
> PR fortran/99169 - Do not clobber allocatable intent(out) dummy argument
>
> gcc/fortran/ChangeLog:
>
> * trans-expr.c (gfc_conv_procedure_call): Do not add clobber to
> allocatable intent(out) argument.
>
> gcc/testsuite/ChangeLog:
>
> * gfortran.dg/intent_optimize_3.f90: New test.
>
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-20 21:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 21:16 [PATCH] PR fortran/99169 - [9/10/11 Regression] Segfault when passing allocatable scalar into intent(out) dummy argument Harald Anlauf
2021-02-20 21:02 ` Tobias Burnus
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).