* {Patch, fortran] PR86372 - [8/9 Regression] Segfault on ASSOCIATE statement with CHARACTER variable
@ 2018-10-08 13:14 Paul Richard Thomas
0 siblings, 0 replies; only message in thread
From: Paul Richard Thomas @ 2018-10-08 13:14 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 492 bytes --]
I have fixed this as 'obvious' on 8-branch(r264925) and trunk(r264915).
Paul
2018-10-08 Paul Thomas <pault@gcc.gnu.org>
Backport from trunk
PR fortran/86372
* trans-stmt.c (trans_associate_var): Character associate names
with variable string length do not have to be deferred length
for the string length to be set, if variable.
2018-10-08 Paul Thomas <pault@gcc.gnu.org>
Backport from trunk
PR fortran/86372
* gfortran.dg/associate_41.f90: New test.
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 1347 bytes --]
Index: gcc/fortran/trans-stmt.c
===================================================================
*** gcc/fortran/trans-stmt.c (revision 264912)
--- gcc/fortran/trans-stmt.c (working copy)
*************** trans_associate_var (gfc_symbol *sym, gf
*** 1885,1891 ****
}
if (sym->ts.type == BT_CHARACTER
- && sym->ts.deferred
&& !sym->attr.select_type_temporary
&& VAR_P (sym->ts.u.cl->backend_decl)
&& se.string_length != sym->ts.u.cl->backend_decl)
--- 1885,1890 ----
Index: gcc/testsuite/gfortran.dg/associate_41.f90
===================================================================
*** gcc/testsuite/gfortran.dg/associate_41.f90 (nonexistent)
--- gcc/testsuite/gfortran.dg/associate_41.f90 (working copy)
***************
*** 0 ****
--- 1,25 ----
+ ! { dg-do run }
+ !
+ ! Test the fix for PR86372 in which the associate name string length was
+ ! not being set, thereby causing a segfault.
+ !
+ ! Contributed by Janus Weil <janus@gcc.gnu.org>
+ !
+ program xxx
+
+ character(len=50) :: s
+
+ s = repeat ('*', len(s))
+ call sub(s)
+ if (s .ne. '**'//'123'//repeat ('*', len(s) - 5)) stop 1
+
+ contains
+
+ subroutine sub(str)
+ character(len=*), intent(inout) :: str
+ associate (substr => str(3:5))
+ substr = '123'
+ end associate
+ end subroutine
+
+ end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-10-08 13:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 13:14 {Patch, fortran] PR86372 - [8/9 Regression] Segfault on ASSOCIATE statement with CHARACTER variable Paul Richard Thomas
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).