This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/86372] [8/9 Regression] Segfault on ASSOCIATE statement with CHARACTER variable
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 02 Jul 2018 09:11:36 +0000
- Subject: [Bug fortran/86372] [8/9 Regression] Segfault on ASSOCIATE statement with CHARACTER variable
- Auto-submitted: auto-generated
- References: <bug-86372-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86372
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
--- Comment #1 from janus at gcc dot gnu.org ---
Test case:
program xxx
character(len=50) :: s
s = repeat('*', len(s))
call sub(s)
print *, s
contains
subroutine sub(str)
character(len=*), intent(inout) :: str
associate (substr => str(3:5))
substr = '123'
end associate
end subroutine
end
With gfortran version 5 to 7 it compiles ok and prints at runtime:
**************************************************
This is already wrong, since the string should be modified is the subroutine.
With gfortran 8 and trunk there is even a segfault at runtime (on the line
"substr = '123'"), and the warning mentioned in PR 56670 comment 5:
substr = '123'
Warning: ‘.substr’ is used uninitialized in this function [-Wuninitialized]