This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/69423] [6 Regression] Invalid optimization with deferred-length character
- From: "pault at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 02 Feb 2016 18:18:33 +0000
- Subject: [Bug fortran/69423] [6 Regression] Invalid optimization with deferred-length character
- Auto-submitted: auto-generated
- References: <bug-69423-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69423
--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
Dear Anthony,
In reply to your email message, this one is high on my list of PRs to fix. A
workaround, which could be permanent, is:
program tester
character(LEN=:), allocatable :: S
S= test(2)
print *, S
contains
function test(alen) result(rtest)
character(LEN=:), allocatable :: rtest
integer alen, i
do i = alen, 1, -1
rtest = 'test'
exit
end do
!This line prints nothing when compiled with -O1 and higher
print *, rtest
end function test
end program tester
At the moment, I cannot see why an explicit function result should be
different. The code displayed with -fdump-tree-original looks to be the same!
I have set things up in previous patches such that the string length is an
indirect reference to that in the caller. Apparently, in the original testcase
the reference is broken. The memory allocated to 'test' is correct but the
string length remains zero. Even weirder is that this is specific to DO
blocks....
That said, if Andre can see a way to fix it, I would be more than happy to let
him do it :-)
Cheers
Paul