[Bug fortran/69423] [6 Regression] Invalid optimization with deferred-length character
pault at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 2 18:18:00 GMT 2016
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
More information about the Gcc-bugs
mailing list