diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2018-10-08 09:11:03 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2018-10-08 09:11:03 +0000 |
commit | c16ac98ea9cddb4725dd5c6d010bdeaac14d1a25 (patch) | |
tree | c41120f5224f3a10a68aed3140ae1ffa65488929 /gcc | |
parent | a52cdecf114f4f1e5acbdeeb28b9381875a4b9a8 (diff) | |
download | gcc-c16ac98ea9cddb4725dd5c6d010bdeaac14d1a25.zip gcc-c16ac98ea9cddb4725dd5c6d010bdeaac14d1a25.tar.gz gcc-c16ac98ea9cddb4725dd5c6d010bdeaac14d1a25.tar.bz2 |
re PR fortran/86372 (Segfault on ASSOCIATE statement with CHARACTER variable)
2018-10-08 Paul Thomas <pault@gcc.gnu.org>
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>
PR fortran/86372
* gfortran.dg/associate_41.f90: New test.
From-SVN: r264915
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/trans-stmt.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_41.f90 | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index ef9e519..6256e3f 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -1885,7 +1885,6 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block) } 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) diff --git a/gcc/testsuite/gfortran.dg/associate_41.f90 b/gcc/testsuite/gfortran.dg/associate_41.f90 new file mode 100644 index 0000000..9177582a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_41.f90 @@ -0,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 |